In Java, how to find if first character in a string is upper case without regex

Vjy picture Vjy · Dec 15, 2010 · Viewed 135.5k times · Source

In Java, find if the first character in a string is upper case without using regular expressions.

Answer

vitaut picture vitaut · Dec 15, 2010

Assuming s is non-empty:

Character.isUpperCase(s.charAt(0))

or, as mentioned by divec, to make it work for characters with code points above U+FFFF:

Character.isUpperCase(s.codePointAt(0));