|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
change first character to uppercase
1) i need to know how to change a String first character to uppercase.
2) i also how to change all characters to lower case. 3) i also need to know how to replace a space with underscore eg " " to "_". |
|
#2
|
||||
|
||||
|
if you are on unix use sed: here is a simple example of how to change any letter a with b in some file
sed 's/a/b/g' somefile once you can figure out the regular expression it should be easy. if you need help with regex let me know. |
|
#3
|
|||
|
|||
|
Take a look at the docs for java.lang.String: http://java.sun.com/j2se/1.4/docs/a...ang/String.html
|
|
#4
|
|||
|
|||
|
/* Example.java
*/ public class Example{ public static void main(String[] args){ Example example = new Example(); example.test(); } public void test(){ String someString = "la la la la la la la"; /* 1) i need to know how to change a String first character to uppercase. */ String string1 = someString.substring(0,1).toUpperCase() + someString.substring(1); /* 2) i also how to change all characters to lower case. */ String string2 = someString.toUpperCase(); /* 3) i also need to know how to replace a space with underscore eg " " to "_". */ String string3 = someString.replace(' ','_'); System.out.println(someString); System.out.println(string1); System.out.println(string2); System.out.println(string3); } } |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > change first character to uppercase |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|