The Artima Developer Community
Sponsored Link

Java Answers Forum
how do u check if the first letter is uppercase

3 replies on 1 page. Most recent reply: Oct 11, 2002 1:35 AM by Ian Phillips

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Cshah

Posts: 16
Nickname: tkc204
Registered: Oct, 2002

how do u check if the first letter is uppercase Posted: Oct 7, 2002 11:16 PM
Reply to this message Reply
Advertisement
How do you check if the first letter is uppercase in a string. is there a function i can call.


siddhartha

Posts: 15
Nickname: saddysan
Registered: Jul, 2002

Re: how do u check if the first letter is uppercase Posted: Oct 8, 2002 11:10 AM
Reply to this message Reply
just extract the first character and compare ist ascii value from the range of Uppercase Ascii characters, if it is in the range it is in uppercase otherwise not. If you need more help tell me

saddysan

Don Hill

Posts: 70
Nickname: ssswdon
Registered: Jul, 2002

Re: how do u check if the first letter is uppercase Posted: Oct 8, 2002 11:22 AM
Reply to this message Reply
well thats the hard way, why not just use the API,
get the first letter as a char

char chr = myString.charAt(0);
boolean upper = Character.isUpperCase( chr);

HTH

Ian Phillips

Posts: 8
Nickname: ianp
Registered: Oct, 2002

Not by comparing ASCII values! Posted: Oct 11, 2002 1:35 AM
Reply to this message Reply
This isn't just more work, it's wrong since it doesn't take into account I18N considerations. As Don says, you have to use the isUpperCase method to check this.

An example, your test would result in an incorrect result for the string "\u0916" (the letter KHA in Devangari).

Yours,
Ian.

Flat View: This topic has 3 replies on 1 page
Topic: problem with this function Previous Topic   Next Topic Topic: how do i do a palindrome

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use