How i take a line string input through keyboard ?.
Example :
I am a student .

Recommended Answers

All 3 Replies

Yes,you have certain options like Scanner and BufferedReader(connected to InputStreamReader) to accomplish the task.

Well to take input from the keyboard you could use java.util.Scanner and store the input to the string.

Ex.

Scanner s = new Scanner(System.in); //Defining the scanner object(Remember to import java.util.Scanner)

System.out.println("Enter string");//asking for input
String name = s.nextLine();//Taking in the input and storing it into a string
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.