Write a java program to get a input string from the user and store it in a string variable and output the same to console.
http://www.coderegister.co.in
Output:
You've entered string: "http://www.coderegister.co.in
Java Implementation:
Using Scanner Class:
import java.util.*; import java.lang.*; import java.io.*; class CodeRegister { public static void main (String[] args) throws java.lang.Exception { Scanner in = new Scanner(System.in); String str = in.next(); System.out.println("You've entered string: \""+str+"\""); } }Using BufferedReader Class:
import java.util.*; import java.lang.*; import java.io.*; class CodeRegister { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); System.out.println("You've entered string: \""+str+"\""); } }