Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • 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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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