What is a Java equivalent for this C++ code snippet:

string str ;
while(cin>>str){
   //code
}

没有正确的解决方案

其他提示

Something like this

String str ; 
while((str = System.in.readLine()) != null){
   //code
}
Scanner scanner = new Scanner(System.in);
String sentence = scanner.nextLine();
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
}

you can do it either with a GUI style .

import javax.swing.JOptionPane;
String Input=JOptionPane.showInputDialog("Title","Message");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top