Код: Выделить всё
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String text;
for(int isRunning= 1; isRunning != 0;){
System.out.println("Enter a string value");
text = sc.nextLine();
System.out.println(text);
System.out.println("Enter 0 if you want to exit, or enter any other number if you want to proceed again");
isRunning= sc.nextInt();
}
}
Код: Выделить всё
Enter a string value
Hello World
Hello World
Enter 0 if you want to exit, or enter any other number if you want to proceed again
3
Enter a string value
Hello World
Hello World
Enter 0 if you want to exit, or enter any other number if you want to proceed again
0
Код: Выделить всё
Enter a string value
Hello World
Hello World
Enter 0 if you want to exit, or enter any other number if you want to proceed again
3
Enter a string value
Enter 0 if you want to exit, or enter any other number if you want to proceed again
3
Enter a string value
Enter 0 if you want to exit, or enter any other number if you want to proceed again
UGHHH
Заранее спасибо!
Подробнее здесь: https://stackoverflow.com/questions/787 ... e-for-loop