cara mengambil input terpisah ruang di java
String s[]= scanner.nextLine().split(" ");for(int i =0 ;i < s.length;i++){ a[i]= Integer.parseInt(s[i]);}
Lucky Lapwing
String s[]= scanner.nextLine().split(" ");for(int i =0 ;i < s.length;i++){ a[i]= Integer.parseInt(s[i]);}
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
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]);
}
}