Answers for "how to take 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
0

how to take space separated input in java

import java.util.*;

public class buffer 
{
	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		System.out.println();
		int i;
		 int a[]=new int[100];
		 String s[]= scan.nextLine().split(" ");
		for(i =0 ;i < s.length;i++){
		 a[i]= Integer.parseInt(s[i]);
		}
		for(i =0 ;i < s.length;i++)
		 System.out.println(a[i]);
	}
}
Posted by: Guest on August-26-2021

Code answers related to "how to take space separated input in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language