Answers for "how to read space separated characters in java"

0

how to read space separated characters in java

# Let input sequence is like ' A B C D E F ( 9 5 a b z '

while(Scanner.hasNextLine()){
  String[] c = fileReader.nextLine().split(" ");
  for(int i=0;i<c.length;i++){
      System.out.print("My character is " + c[i] + " "); 
      // this is enough for the input sequence
      // but if you want a safe approach then use it
      for(int j=0;j<c[i].length;j++){
          System.out.print("My character is " + c[j].charAt(j) + " ");
   	  }
}
Posted by: Guest on May-27-2021

Code answers related to "how to read space separated characters in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language