[Java] Judgment by entering characters in the terminal

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

[Java] Judgment by entering characters in the terminal
Read the packet capture obtained by tcpdump in Java
[Java] Integer information of characters in a text file acquired by the read () method
Play non-XML valid characters in Java by specifying code values
Access the network interface in Java
Guess the character code in Java
Specify the java location in eclipse.ini
Unzip the zip file in Java
Parsing the COTOHA API in Java
Call the super method in Java
Web application structure by Java and processing flow in the presentation layer
Get the result of POST in Java
Duplicate Map sorted by key in Java
Java reference to understand in the figure
Try using the Stream API in Java
I tried the new era in Java
[Java] Use cryptography in the standard library
Organized memo in the head (Java --Array)
Try calling the CORBA service in Java 11+
This and that of the implementation of date judgment within the period in Java
What is the main method in Java?
How to get the date in java
The story received by Java SE11 silver
The story of writing Java in Emacs
Console input in Java (understanding the mechanism)
[Java] Color the standard output to the terminal
[Java] Check the number of occurrences of characters
Sort by multiple fields in the class
[Java] Various methods to acquire the value stored in List by iterative processing
[Java] Rewrite the functions created by myself in the past from java.io.File with NIO.2.
Parse the date and time string formatted by the C asctime function in Java
Regarding the transient modifier and serialization in Java
[Java] Handling of JavaBeans in the method chain
About the confusion seen in startup Java servers
The story of making ordinary Othello in Java
About the idea of anonymous classes in Java
A story about the JDK in the Java 11 era
Organized memo in the head (Java --Control syntax)
Use the JDK used in Android Studio in the terminal
Measure the size of a folder in Java
Feel the passage of time even in Java
[Java] Read the file in src / main / resources
Organized memo in the head (Java --Data type)
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Try using the COTOHA API parsing in Java
[Java] Something is displayed as "-0.0" in the output
Import files of the same hierarchy in Java
How to check Rails commands in the terminal
[Java] The word passing by reference is bad!
Replacing system environment variables by reflection in java
Partization in Java
[Java] How to get the key and value stored in Map by iterative processing
Changes in Java 11
Rock-paper-scissors in Java
Pi in Java
# 1_JAVA I want to get the index number by specifying one character in the character string.
FizzBuzz in Java
[Java] How to display the day of the week acquired by LocalDate, DateTimeformatter in Japanese
Get the URL of the HTTP redirect destination in Java
Format of the log output by Tomcat itself in Tomcat 8