当前位置: 技术问答>java相关
请问如何输入,输出整数,字符,浮点数?
来源: 互联网 发布时间:2015-10-18
本文导语: 请给出范例,谢谢! | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s1; String s2; String s3; System.out.println("Enter a int data(i): "); s1 = br.readLine(); int i = Integer.parseInt(s1); Sys...
请给出范例,谢谢!
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s1;
String s2;
String s3;
System.out.println("Enter a int data(i): ");
s1 = br.readLine();
int i = Integer.parseInt(s1);
System.out.println("Enter a double data(d): ");
s2 = br.readLine();
double d = Double.parseDouble(s2);
System.out.println("Enter a string(s): ");
s3 = br.readLine();
System.out.println("i = " + i);
System.out.println("d = " + d);
System.out.println("s = " + s3);
String s1;
String s2;
String s3;
System.out.println("Enter a int data(i): ");
s1 = br.readLine();
int i = Integer.parseInt(s1);
System.out.println("Enter a double data(d): ");
s2 = br.readLine();
double d = Double.parseDouble(s2);
System.out.println("Enter a string(s): ");
s3 = br.readLine();
System.out.println("i = " + i);
System.out.println("d = " + d);
System.out.println("s = " + s3);