+ 3
in c program we write scanf statement .what we have to take in java to read the statement??
2 Antworten
+ 2
To read a string in JAVA , we either use BufferedReader or Scanner .
Using Scanner :
Scanner sc=new Scanner (System.in);
String x=sc.next();
you are ready to input the string now .
btw BufferedReader is better way to take input .
0
Scanner scanner = new Scanner(System.in);
scanner.<appropriate method>