0
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner("(10,{10,9,6,5}),(12,{5,6})");
String s=sc.nextLine();
String[] strArray = s.split("[(,{})]");
for(int i=0;i <strArray.length; i++)
{
    System.out.println(strArray[i]);
}
int[] intArray = new int[strArray.length];
for(int i = 0; i < strArray.length; i++) 
{
if(strArray[i]!=" ")
{
    intArray[i] = Integer.parseInt(strArray[i]);
}
}
System.out.println(strArray.length);
}
}

/*Output:


Runtime error ......

10

10 9 6 5

12

5 6


When printing on different lines there is blank spaces in between.

When printing on same line output:10109651256.

length of splitted array is 14.

What are these spaces blanks or NULL?

Why aren't they printing on the same line?//

sfbjabf
  • 1
  • 1

0 Answers0