1 /**
2 * THis_is_a_cat
3 * This Is A Cat
4 *
5 * Cat A Is This
6 * @author Administrator
7 *
8 */
9 public class Test07Str {
10 public static void main(String[] args) {
11 String s="THiS_is_a_cat";
12 //Split
13 String[] arr =s.split("_");
14 //Declare new string
15 // String sumStr="";
16 String sumStr=new String();
17 //Add directly to sumStr when traversing
18 for(int i=0;i){
19 // System.out.println(arr[i].substring(0, 1).toUpperCase());
20 // System.out.println(arr[i].substring(1).toLowerCase());
21 sumStr+=arr[i].substring(0, 1).toUpperCase()+arr[i].substring(1).toLowerCase ()+" ";
22 }
23 System.out.println("Converted:"+ sumStr);
24
25 System.out.println("---------------------- ---");
26 //Empty it
27 sumStr="";
28 for(int i=arr.length-1;i>=0;i--){
29 sumStr+=arr[i].substring(0, 1).toUpperCase()+arr[i].substring( 1).toLowerCase()+" ";
30 }
31 System.out.println("Converted:"+ sumStr);
32 }
33 }
Split(Split character or regular expression); Return value String[]Array
SubString() :Intercept substring
SubString( from), The range of intercepted substring[from, len-1] FromfromIntercept to the end
SubString(from,to) , the intercepted sub String range:[from, to) Left closed, right open, interception The number of characters in the substring= to-from
toUpperCase() :turn to uppercase
< /p>
toLowerCase():: turn to lowercase
< /p>
StringBuffer/StringBuild: Variable character sequence
Append(): Can be used for string splicing
p>
1 /**
2 * THis_is_a_cat
3 * This Is A Cat
4 *
5 * Cat A Is This
6 * @author Administrator
7 *
8 */
9 public class Test07Str {
10 public static void main(String[] args) {
11 String s="THiS_is_a_cat";
12 //Split
13 String[] arr =s.split("_");
14 //Declare new string
15 // String sumStr="";
16 String sumStr=new String();
17 //Add directly to sumStr when traversing
18 for(int i=0;i){
19 // System.out.println(arr[i].substring(0, 1).toUpperCase());
20 // System.out.println(arr[i].substring(1).toLowerCase());
21 sumStr+=arr[i].substring(0, 1).toUpperCase()+arr[i].substring(1).toLowerCase ()+" ";
22 }
23 System.out.println("Converted:"+ sumStr);
24
25 System.out.println("---------------------- ---");
26 //Empty it
27 sumStr="";
28 for(int i=arr.length-1;i>=0;i--){
29 sumStr+=arr[i].substring(0, 1).toUpperCase()+arr[i].substring( 1).toLowerCase()+" ";
30 }
31 System.out.println("Converted:"+ sumStr);
32 }
33 }