app.java
import java.io.*;
/**
* app
*/
public class app {
public static void main(String[] args)throws IOException
{
// System.in is an instance of InputStream
//Create a string stream new InputStreamReader();
//Buffer new BufferedReader();
//Read line of text readLine()
//Equals to compare()
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String res1 = "namari";
String res2 = "25";
System.out.println("Please enter your name and age.");
System.out.println("Name is?");
String name = br.readLine();
System.out.println("How old are you?");
String old = br.readLine();
if (name.equals(res1) && old.equals(res2)) {
System.out.println("OK");
} else {
System.out.println("NG");
}
}
}
Terminal
$ javac app.java
$ java app
Please enter your name and age.
Name is?
namari
How old are you?
25
OK
Recommended Posts