Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Checking if a string contains upper or lower case letters

string

  • Please log in to reply
1 reply to this topic

#1 ahwoo

ahwoo

    CC Newcomer

  • Member
  • PipPip
  • 16 posts
  • Programming Language:Java
  • Learning:Java

Posted 03 September 2012 - 09:33 PM

Hi,
I have to receive user input via the scanner, and then
check if the word they entered contains upper or lowercase letters,

would the method isUpperCase & isLowerCase work??
If so how would you apply it to strings.

Or would i have to use string.length and char.At??


Thanks any help is appreciated
  • 0

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 03 September 2012 - 10:23 PM

Yes you should loop over the String with the help of String.length and String.charAt(index);

Or, alternatively:
for(char character : string.toCharArray() ){
   //do stuff with character.
}

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download