It’s not easy for newcomer to learn java-application’s iostream.
Now from what I learn, I should creat a Reader to read what the user type, then create a BufferedReader to store the keywords.After doing that I can create String to readLine().
Here is the methods:
public static String inputLine() {
BufferedReader br = null;
Reader r = new InputStreamReader(System.in);
br = new BufferedReader(r);
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
By the way,When I want to get an int,I shoule convert the string.
Integer.parseInt(inputLine());