Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.Scanner;
- public class ReadString {
- public static void main(String[] args) {
- String str;
- Scanner input = new Scanner(System.in);
- System.out.print("Enter strings, enter DONE when finished: ");
- str = input.nextLine();
- do {
- if ((str.length() > 20)) {
- throw new StringTooLongException();
- } else {
- System.out.print("Enter strings, enter DONE when finished: ");
- str = input.nextLine();
- }
- } while(!str.equalsIgnoreCase("done"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement