Last active
August 29, 2015 14:22
-
-
Save wzpan/80fcdba6cc99f4b0f921 to your computer and use it in GitHub Desktop.
Java keyboard IO.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class HelloWorld | |
{ | |
public static void main(String args[]) | |
{ | |
InputStreamReader sin = new InputStreamReader(System.in); | |
BufferedReader br = new BufferedReader(sin); | |
System.out.println("Type your name: "); | |
try{ | |
String name = br.readLine(); | |
System.out.println("Type num: "); | |
String nums = br.readLine(); | |
int num = Integer.parseInt(nums); | |
for (int i=0; i<num; i++) { | |
System.out.println("Hello " + name); | |
} | |
} catch (Exception e) { | |
System.out.println(e.toString()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.Scanner; | |
public class TestScanner { | |
public static void main(String [] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("请输入你的姓名:"); | |
String name = sc.nextLine(); | |
System.out.println("请输入你的年龄:"); | |
int age = sc.nextInt(); | |
System.out.println("请输入你的工资:"); | |
float salary = sc.nextFloat(); | |
System.out.println("你的信息如下:"); | |
System.out.println("姓名:"+name+"\n"+"年龄:"+age+"\n"+"工资:"+salary); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment