Solved

String Manipulation

Posted on 2004-04-08
4
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

690 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