Solved

String Manipulation

Posted on 2004-04-08
4
320 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
0
Comment
Question by:Orlando15767
  • 3
4 Comments
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 75 total points
ID: 10786934
String capitalized = original.substring(0,1).toUpperCase() + original.substring(1);
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10787003
or you can use this ("original" is your original String):

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

Author Comment

by:Orlando15767
ID: 10787029
perfect.
thanks for the help
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10787143
:°)
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
netstat -ano | find "8000" and taskkill /f /pid 2984 3 83
egit plugin on eclipse 8 82
SHA2 certs for IIS AND Java? 2 113
iterator/ListIterator approach 17 39
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question