Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WorkingWithAbstraction;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Read commands from the scanner each on a new line until the command equals "End"
- // In other words:
- // Read Strings from the console until the user enters "End"
- // Option 1:
- String command1 = scanner.nextLine();
- while(!"End".equals(command1)){
- command1 = scanner.nextLine();
- }
- // Option 2:
- String command2;
- while(!"End".equals(command2 = scanner.nextLine())){
- }
- // Option 2 for beginners:
- String command3 = "";
- while(!"End".equals(command3 = scanner.nextLine())){
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement