Answers for "Print the characters in a string separated by space 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
0

Read array of characters from space separated values in java

List<Character> collect = Arrays.stream(scanner.nextLine().split(" "))
                       .map(a -> new a.charAt(0)).collect(Collectors.toList());
Posted by: Guest on May-27-2021
0

Read array of characters from space separated values in java

List<Character> collect = Arrays.stream(scanner.nextLine().split(" "))
                       .map(a -> new a.charAt(0)).collect(Collectors.toList());
Posted by: Guest on May-27-2021
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 "Print the characters in a string separated by space java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language