What is a Java equivalent for this C++ code snippet:
string str ;
while(cin>>str){
//code
}
What is a Java equivalent for this C++ code snippet:
string str ;
while(cin>>str){
//code
}
Scanner scanner = new Scanner(System.in);
String sentence = scanner.nextLine();
while loop?Scanner scanner = new Scanner(System.in);
boolean flag = true;
while(flag)
{
String str = scanner.nextLine();
// Add any condition to set flag = false to exit from while loop
}
String str = null; while ((str = scanner.nextLine() != null) { ... }.