Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

String Manipulation

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
0
Orlando15767
Asked:
Orlando15767
  • 3
1 Solution
 
GrandSchtroumpfCommented:
String capitalized = original.substring(0,1).toUpperCase() + original.substring(1);
0
 
GrandSchtroumpfCommented:
or you can use this ("original" is your original String):

String capitalized = Character.toUpperCase(original.charAt(0)) + original.substring(1);
0
 
Orlando15767Author Commented:
perfect.
thanks for the help
0
 
GrandSchtroumpfCommented:
:°)
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();
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now