Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

get input in java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Sample {

    public static void main(String[] args) {
        BufferedReader datain = new BufferedReader(new InputStreamReader(System.in));
        String name = "";
        System.out.print("Enter your name:");
        try {
            name = datain.readLine();
        } catch (IOException e) {
            System.out.print("Error");

        }
        System.out.println("Hello! " + name + "!");
    }

}
Source by nullorempty.org #
 
PREVIOUS NEXT
Tagged: #input #java
ADD COMMENT
Topic
Name
2+6 =