标签:
String str="qwerwer"; int index=str.indexOf(‘w‘); System.out.println(index);// 结果是1 String str1="we"; int index1=str1.indexOf(‘w‘);
System.out.println(index1);//结果是0
int index2=str.lastIndexOf(‘w‘);
System.out.println(index2);//结果是4
String s7="tOm"; String s8="ToM"; System.out.println(s7.equalsIgnoreCase(s8));//忽略大小写 System.out.println(s7.toLowerCase());//转化小写 System.out.println(s8.toUpperCase());//转化大写 String s9="2412"; String s10="sdasd"; System.out.print("电脑:"+s9+"西瓜:"+s10+"\n"); System.out.println(s9.concat(s10));//字符串连接
String str3="3525erw.java"; String sub=str3.substring(3);//截取索引3以后的 System.out.println(sub); String str4=" i love code"; String sub1=str4.substring(4, 8);//4截取,但8不截取 System.out.println(sub1); String sub2=str4.trim();//只截取开始结尾的空格,中间的不截取 System.out.println(sub2);
String str3="3525erw.java"; System.out.println(str3.lastIndexOf(".java")); System.out.println(str3.endsWith(".java")); System.out.println(str3.startsWith("352")); System.out.println(str3.endsWith(".jAva"));//大小写敏感
标签:
原文地址:http://www.cnblogs.com/infernofranz/p/5726746.html