We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

String Manipulation

Orlando15767
Orlando15767 asked
on
Medium Priority
356 Views
Last Modified: 2010-03-31
is there a way to take the first character of a string and change that character to upper case?

ex: word     needs to be changed to:    Word

thanks for the help
Comment
Watch Question

Top Expert 2006
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Top Expert 2006

Commented:
or you can use this ("original" is your original String):

String capitalized = Character.toUpperCase(original.charAt(0)) + original.substring(1);

Author

Commented:
perfect.
thanks for the help
Top Expert 2006

Commented:
:°)
You are welcome.
Actually you might want to use this instead, it should be more efficient (event if it's a little more code):

    StringBuffer sbuff = new StringBuffer(original);
    sbuff.setCharAt(0, Character.toUpperCase(sbuff.charAt(0)));
    String capitalized = sbuff.toString();
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.