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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:55:06+00:00 2026-06-12T09:55:06+00:00

I am trying to use a for loop to examine every character in a

  • 0

I am trying to use a for loop to examine every character in a single dimensional string array and print “Character [a] is uppercase” or “Character [b] is lowercase” or “Character [c] is a space.” I also have to print the index number and the character in that index.

I thought I was supposed to create separate strings with uppercase letters and lowercase letters but turns out I was wrong. I also don’t know if I’m supposed to convert the string array into a char array?

I think I’m supposed to use charAt() method but I don’t know how.

This is what I had done:

for(x = 0; x < fullName.length(); x++)
{
    if(fullName[0] == nameUpperCase[2]);
    {
        System.out.print("character [0] located at position [0] is  lowercase");
    }

    if(fullName[1] == nameLowerCase[4]);
    {
        System.out.print("character [b] located at position [1] is uppercase"); 
    }
}

As you can see, I couldn’t even figure out how to use the loop to print ‘a’ or ‘b’ and so I had to manually insert each one along with the position they’re in…

  • 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-12T09:55:08+00:00Added an answer on June 12, 2026 at 9:55 am

    If you’re comparing two Strings (ie the arrays are String[]) then your code is comparing the memory reference of each string, which will be different.

    In order to compare String for equality, you need to use the equals method.

    for(x = 0; x < fullName.length(); x++)
    {
        if(fullName[0].equals(nameUpperCase[2]));
        {
            System.out.print("character [0] located at position [0] is  lowercase");
        }
    
        if(fullName[1].equals(nameLowerCase[4]));
        {
            System.out.print("character [b] located at position [1] is uppercase"); 
        }
    
    }
    

    I would also recommend you take some of the ideas from the other answers.

    Convert the original String to a char array instead…

    char[] fullName = name.toCharArray();
    

    Or you could simply get the char at the given index…

    for(x = 0; x < originalString.length(); x++)
    {
        char charAt = originalString.charAt(x);
        if(Character.isUpperCase(charAt));
        {
            System.out.print("character [0] located at position [0] is  lowercase");
        }
    
        if(Character.toUpperCase(originalString.charAt(1)) == originalString.charAt(4));
        {
            System.out.print("character [b] located at position [1] is uppercase"); 
        }
    
    }
    

    Updated example

    Now that we’ve established that we can’t compare String values with ==, here’s a working example of what I think you want achieve…

    String value = "This is a simple string";
    for (int index = 0; index < value.length(); index++) {
    
        String whatIs = "Unknown";
        if (Character.isUpperCase(value.charAt(index))) {
            whatIs = "Upper case";
        } else if (Character.isLowerCase(value.charAt(index))) {
            whatIs = "Lower case";
        } else if (Character.isSpaceChar(value.charAt(index))) {
            whatIs = "Space";
        } else if (Character.isDigit(value.charAt(index))) {
            whatIs = "Digit";
        }
    
        System.out.println("Character @ " + index + " (" + value.charAt(index) + ") is a " + whatIs + " character");
    
    }
    

    Which outputs

    Character @ 0 (T) is a Upper case character
    Character @ 1 (h) is a Lower case character
    Character @ 2 (i) is a Lower case character
    Character @ 3 (s) is a Lower case character
    Character @ 4 ( ) is a Space character
    Character @ 5 (i) is a Lower case character
    Character @ 6 (s) is a Lower case character
    Character @ 7 ( ) is a Space character
    Character @ 8 (a) is a Lower case character
    Character @ 9 ( ) is a Space character
    Character @ 10 (s) is a Lower case character
    Character @ 11 (i) is a Lower case character
    Character @ 12 (m) is a Lower case character
    Character @ 13 (p) is a Lower case character
    Character @ 14 (l) is a Lower case character
    Character @ 15 (e) is a Lower case character
    Character @ 16 ( ) is a Space character
    Character @ 17 (s) is a Lower case character
    Character @ 18 (t) is a Lower case character
    Character @ 19 (r) is a Lower case character
    Character @ 20 (i) is a Lower case character
    Character @ 21 (n) is a Lower case character
    Character @ 22 (g) is a Lower case character
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a foreach loop for an array of objects. Inside of
In a for loop, I am trying to use printf to print the current
Im trying to use a loop to cycle through an array, and in each
I have an array of 28 characters. I'm trying to use a for loop
when trying to use a loop to create a jagged array, but what happens
HI, I'm trying to use for loop to find the difference between every two
I am trying to use for..in loop to access the description key/value within 'Event'
I'm trying to use Linq to loop through all fonts in the %windir%\Fonts folder
I'm trying to use the foreach loop in an Ant script but I get
I'm trying to use a cursor loop in MYSQL, but it's not working. I've

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.