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 7533469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:44:05+00:00 2026-05-30T05:44:05+00:00

I just started with java a few weeks ago, and am trying to make

  • 0

I just started with java a few weeks ago, and am trying to make a program to verify that a password is at least 10 characters, has at least one each of:upper case, lower case, number, and is only alphanumeric characters.

Below is the code I have so far. It’s more English than code actually, but what I’m trying to do is run several loops under one boolean (at least that’s what I think I’m doing). Can you help me understand how exactly booleans work, and if it’s possible for several conditions to be tested under one boolean, as I’m trying to do below?

Thanks!

public class validatingPassword
{
public static void main(String[] args) 
{
String password= isSecurePassword("testcase");
System.out.println(isSecurePassword);
}

public static boolean isSecurePassword(String password)
{   
password.charAt(x);
int lengthPassword= password.length(); 
if (lengthPassword < 10);
return false; 

for (int x = 0; x < lengthPassword; x++)
        {
    if ('A' <=x && x <= 'Z');}
    else if 
    return false;

    for (int x = 0; x< lengthPassword; x++) 
            {
        ('a' <=x && x <= 'z'); }
        else if 
        return false:

        for (int x = 0; x < lengthPassword; x++) 
                {
            ('0' <=x && x <= '9');}
            return true;  
                }
    else if
    {
    x++;
    return false;
    }
    }
}
  • 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-05-30T05:44:06+00:00Added an answer on May 30, 2026 at 5:44 am

    I just give the correct code undocumented. Because I think you’ve got the right ideas, but are missing a bit of Java syntax. You might debug the code with single-step through all commands.

    public class ValidatingPassword {
    
        public static void main(String[] args) {
            String[] passwords = { "testcase", "T3stCas3%45" };
            for (String password : passwords) {
                System.out.println(password + " : " + isSecurePassword(password));
            }
        }
    
        /**
         * Is this a secure password?
         * At least 10 characters, at least one capital letter, one small
         * letter and one digit.
         * 
         * @param password never null.
         * @return whether password is secure.
         */
        public static boolean isSecurePassword(String password) {
    
            int lengthPassword = password.length();
            if (lengthPassword < 10) {
                return false;
            }
    
            boolean hasCapital = false;
            boolean hasSmallLetter = false;
            boolean hasDigit = false;
            for (int i = 0; i < lengthPassword; i++) {
                char ch = password.charAt(i);
                if ('A' <= ch && ch <= 'Z') {
                    hasCapital = true;
                }
                if ('a' <= ch && ch <= 'z') {
                    hasSmallLetter = true;
                }
                if ('0' <= ch && ch <= '9') {
                    hasDigit = true;
                }
            }
            return hasCapital && hasSmallLetter && hasDigit;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started with Java servlets few days ago. I am trying to develop
How would you explain to someone who has just started programming in Java, what
Recently started programming Android Java (Eclipse), Im trying to make a simple reader app
Just started writing java / android and I am trying to use android.widget.VideoView. I
Just started using Java (for Android, if that matters) and all I want is
I just started learning code (Java specifically), and i'm testing out a password system
I started learning c++ about 3 weeks ago after 2 years of java. It
I just started working with Android apps and was trying few sample programs. I
I just started with Java and downloaded Netbeans, i kind of like it, but
I've just started using Java's enums in my own projects (I have to use

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.