java how to enter a string of numbers in the keyboard and then into the array?

import java.util.Scanner;

public class Tset {

public static void main(String[] args) {

System.out.println ( "Please enter the three numbers:");

Scanner in = new Scanner(System.in);

int[] b=new int[3];

for(int i=0;i<b.length;i++){

b[i]=in.nextInt();

}

// iterate

for(int i=0;i<b.length;i++){

System.out.println("b["+i+"]="+b[i]);

}

}

}

Remember, press the Enter key to enter a number

 

Guess you like

Origin www.cnblogs.com/guankelei/p/11446910.html
Recommended