Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EnterAgain {
- public static void main(String[] args) {
- Scanner StdIn = new Scanner(System.in);
- // Initialize the string to be empty
- // This makes it so that we ALWAYS enter the loop initially no matter what
- String userinput = "";
- // Loop indefinitely iff the userinput is empty
- while(userinput.length() == 0){
- System.out.print("Enter a word: ");
- userinput = StdIn.nextLine();
- }
- // If we have successfully broken the loop
- // print the userinput length (meaning this can not be an empty string)
- System.out.println(userinput.length());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement