WhYuLoOkIn
Junior Poster in Training
55 posts since Jan 2007
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
Well if you use the replace method you will have to hard code your code. Which is ok if you know what the string variable contains, In a case where you don't know, this will not be good. So It is probably good if you get familiar with the toUpperCase method in the Character class.
Here is an example how to use it:
String unknown = " java";
//charAt gets the first character in string and upperCase converts it to uppercase
//then I add the uppercase J to the rest of the String with substring starting at the second
//character in the string java, so basically: J + ava -> Java
unknown = Character.toUpperCase(unknown.charAt(0)) + unknown.substring(1);
WhYuLoOkIn
Junior Poster in Training
55 posts since Jan 2007
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
Question Answered as of 5 Years Ago by
WhYuLoOkIn