Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:59:56+00:00 2026-06-17T20:59:56+00:00

I am writing a program that verifies if a password meets the appropriate requirements.

  • 0

I am writing a program that verifies if a password meets the appropriate requirements. I have all of my code written, and I feel it should work, but I get the following error:

Exception in thread "main" java.lang.StackOverflowError
at java.lang.String.length(String.java:623)
at PasswordVerifier.isValid(PasswordVerifier.java:5)
at PasswordVerifier.isValid(PasswordVerifier.java:6)

and then it repeats the last line of the error for quite some time. I’ve been looking around and cannot seem to figure out my issue. I know something is continually looping that I don’t want to, but the fix eludes me. Here is my code

 public class PasswordVerifier{
  private static int MIN_PASSWORD_LENGTH = 6;

  public static boolean isValid(String str){
     if (str.length() >= MIN_PASSWORD_LENGTH){
        if (PasswordVerifier.isValid(str) == true){
           if (PasswordVerifier.hasUpperCase(str) == true){
              if (PasswordVerifier.hasLowerCase(str) == true){
                 if (PasswordVerifier.hasDigit(str) == true){
                    return true;
                 }
              }
           }
        }
     }
        return false;
  }

  private static boolean hasUpperCase(String str){
     for (char c : str.toCharArray()){
        if (Character.isUpperCase(c)){
           return true;
        }
     }
     return false;
  }

  private static boolean hasLowerCase(String str){
     for (char c : str.toCharArray()){
        if (Character.isLowerCase(c)){
           return true;
        }
     }
     return false;
  }

  private static boolean hasDigit(String str){
     for (char c : str.toCharArray()){
        if (Character.isDigit(c)){
           return true;
        }
     }
     return false;
  }
 }

Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:59:57+00:00Added an answer on June 17, 2026 at 8:59 pm
    public static boolean isValid(String str){
        // ...
            if (PasswordVerifier.isValid(str) == true){
            // ...
            }
        // ...
    }
    

    You’re calling isValid(String) from within itself, which is causing the infinite loop recursion.

    I’m going to take a wild guess and say this is what you want instead:

    public static boolean isValid(String str){
        if (str.length() >= MIN_PASSWORD_LENGTH){
            // Removed call to .isValid(String)
            if (PasswordVerifier.hasUpperCase(str)){
                if (PasswordVerifier.hasLowerCase(str)){
                    if (PasswordVerifier.hasDigit(str)){
                        return true;
                    }
                }
            }
        }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im writing a program that should read input via stdin, so I have the
Writing a program that should be portable in Linux and Windows enviroments I have
Im writing a program that should read data from an online XML file. The
I am writing a program that starts another java process which runs certain code.
I'm writing a program that show the thread list of all opened process. With
I have a simple Linux C program that I'm writing to help me better
I have tried writing program that plays a sound file but have been unsuccessful
I'm writing a program that utilises a page's source code, however in certain instances
I'm writing a program that counts all lines, words and characters from a file
I am writing a program that takes all of the text from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.