Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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) + " ");
   	  }
}
Comment

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());
Comment

PREVIOUS NEXT
Code Example
Java :: text with seek bar in android 
Java :: string tmp java 
Java :: java running sum 
Java :: Java Private Access Modifier Error when we call it 
Java ::         System.out.println("Welcome to GeeksforGeeks"); 
Java :: java replace ignore case 
Java :: edit activity main drawer items text color android 
Java :: records java final 
Java :: public class HelloWorld { public static void main( String[] argv ) { int a=4%2*3-1/0; System.out.println(a); } } 
Java :: java spigot string to kyori textcomponent 
Java :: Stringbuilser 
Java :: Java Floating-point Literals 
Java :: Buscando Objeto do Array 
Java :: Reverse Order Output for Java Do-While Loop 
Java :: java consonant regex 
Java :: spigot give item 
Java :: Janaaa_Sa 
Java :: free marker templates 
Java :: java intercambiar la posicion de valores de un array 
Java :: spring mvc aop transaction management 
Java :: how to run javac xlint 
Java :: Java’s generic programming does not apply to the primitive types. True or False? 
Java :: how to declare and allocate memory to array in java 
Java :: java list comparator lambda 
Java :: primefaces p:dataexporter encoding for pdf preProcessor 
Java :: Java Enable assertion in class names 
Java :: what is abstract class 
Java :: scroll 
Java :: java find largest number in list 
Java :: how to access methods from another class in java 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =