Advertisement
Spocoman

01. Read Text

Aug 28th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ReadText {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String text = scanner.nextLine();
  7.         while (!text.equals("Stop")){
  8.             System.out.println(text);
  9.             text = scanner.nextLine();
  10.         }
  11.     }
  12. }
  13.  
  14. ИЛИ:
  15.  
  16. import java.util.Scanner;
  17.  
  18. public class ReadText {
  19.     public static void main(String[] args) {
  20.         Scanner scanner = new Scanner(System.in);
  21.         String text = scanner.nextLine();
  22.         for(int i = 0; !text.equals("Stop"); i++){
  23.             System.out.println(text);
  24.             text = scanner.nextLine();
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement