呵呵,最简单的方法:
import java.util.Scanner;
class test {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
System.out.println(str);
}
}
你输入1 2 3 6 9 8等等
会输出1 2 3 6 9 8
人家说了数组存贮,应该是
import java.util.Scanner;
import java.util.Scanner;
import java.util.regex.Pattern;
public class test1 {
public static void main(String args[]) {
String del=" ";
Scanner sc = new Scanner(System.in);
String str=sc.nextLine();
Pattern p = Pattern.compile(del);
String[] test1 = p.split(str);
for (int i = 0; i
System.out.print(test1[i]+" ");
}
}
}
java.util.Scanner; java.util.regex.Pattern这两个类你好好看看jdk
查查API