日期:2014-05-20 浏览次数:20631 次
public class Test { public static void main(String[]args) { int year, month, day; System.out.println("请输入 年,月,日:"); //C代码:scanf("%d,%d,%d", &year, &month, &day); System.out.println(year+"年"+month+"月"+day+"日); } }
int year, month, day; System.out.println("请输入 年,月,日:"); Scanner scanner = new Scanner(System.in); scanner.useDelimiter("[,\r\n]"); year = scanner.nextInt(); month = scanner.nextInt(); day = scanner.nextInt(); System.out.println(year+"年"+month+"月"+day+"日");
------解决方案--------------------
这个也可以System.in.read();
还有就是用IO流了
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
------解决方案--------------------
import java.util.Scanner;
Scanner input=new Scanner(System.in);
System.out.println( "请输入名字: ");
String name=input.next();
------解决方案--------------------