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]);}
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]);}
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
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]);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us