how to read space separated characters in java

Solutions on MaxInterview for how to read space separated characters in java by the best coders in the world

showing results for - "how to read space separated characters in java"
Edoardo
15 Feb 2017
1# Let input sequence is like ' A B C D E F ( 9 5 a b z '
2
3while(Scanner.hasNextLine()){
4  String[] c = fileReader.nextLine().split(" ");
5  for(int i=0;i<c.length;i++){
6      System.out.print("My character is " + c[i] + " "); 
7      // this is enough for the input sequence
8      // but if you want a safe approach then use it
9      for(int j=0;j<c[i].length;j++){
10          System.out.print("My character is " + c[j].charAt(j) + " ");
11   	  }
12}
similar questions