Answers for "space separated input in java"

4

how to take space separated input in java

String s[]= scanner.nextLine().split(" ");for(int i =0 ;i < s.length;i++){    a[i]= Integer.parseInt(s[i]);}
Posted by: Guest on June-18-2020
1

how to take space separated input in java

Scanner scanner = new Scanner(System.in);
 int numOfBlocks = scanner.nextInt();
 int weightArray[] = new weightArray[numOfBlocks];
 for(int i=0;i<numOfBlocks;i++)
       {
        weightArray[i] = scanner.nextInt();
       }
 scanner.close();
//your logic
Posted by: Guest on June-18-2020

Code answers related to "space separated input in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language