You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importjava.util.*;
publicclassScannerInput {
publicstaticvoidmain(String[] args){
Stringstr = newScanner(System.in).next();
String_str = newScanner(System.in).nextLine();
System.out.println("Here is your word: " + _str);
}
}
next() is used for taking a single word
nextLine() is used for taking a whole line
Taking input using BufferedReader class
importjava.io.*;
publicclassBufferedReaderInput {
publicstaticvoidmain(String[] args) throwsIOException{
Stringstr = newBufferedReader(newInputStreamReader(System.in)).readLine();
System.out.println("Here is what you have written "+str);
}
}