标签:int end log for print prefix mat 前闭后开 csdn 开始
String s1="abcdefgh"; char[] s2={‘1‘,‘2‘,‘3‘}; s1.getChars(1, 3, s2, 0); System.out.print(s2); //输出"bc3"
String s1="abcdefgh"; char[] s2={‘1‘,‘2‘,‘3‘}; s1.getChars(1, 3, s2, 1); System.out.print(s2); //输出"1bc"
String s1="abcdefgh"; String s2="abcde"; String s3="c"; System.out.println(s1.compareTo(s2));//3:s1.length()-s2.length() 8-5=3 System.out.println(s1.compareTo(s3));//-2:‘a‘-‘c‘ System.out.println(s3.compareTo(s1));//2:‘c‘-‘a‘
String s1="abcdefgh"; String s2="Abcde"; String s3="C"; System.out.println(s1.compareToIgnoreCase(s2));//3:s1.length()-s2.length() 8-5=3 System.out.println(s1.compareToIgnoreCase(s3));//-2:‘a‘-‘c‘ System.out.println(s3.compareToIgnoreCase(s1));//2:‘c‘-‘a‘
String s1="abcdefgh"; System.out.println(s1.startsWith("c",2 ));//true System.out.println(s1.startsWith("cd",2 ));//true System.out.println(s1.startsWith("cde",2 ));//true System.out.println(s1.startsWith("ce",2 ));//false System.out.println(s1.startsWith("a"));//true System.out.println(s1.startsWith("ab"));//true System.out.println(s1.startsWith("b"));//false
String s1="abcdefga"; System.out.println(s1.indexOf(97));//97是‘a‘ 返回0 System.out.println(s1.indexOf(98));//98是‘b‘ 返回1 System.out.println(s1.indexOf(99));//99是‘c‘ 返回2 System.out.println(s1.indexOf(105));//105是‘i’,,,没出现 System.out.println(s1.indexOf("d"));//返回3 System.out.println(s1.indexOf("a",7));//返回7
String s1="abcdefga"; System.out.println(s1.replace(‘a‘, ‘d‘));// "dbcdefgd" System.out.println(s1.replace("ab", "#"));// "#cdefga" System.out.println(s1.replaceAll("[a-z]", "#"));// "########"
String s1="1a2b3c4d5e6f7g8a"; String[] res=s1.split("[a-z]"); for(String item:res){ System.out.println(item); } //res={"1","2","3","4","5","6","7","8"}
System.out.println(String.format("%f", 100.0));//100.000000默认六位 System.out.printf("%f %n", 100.0); //100.000000
标签:int end log for print prefix mat 前闭后开 csdn 开始
原文地址:http://www.cnblogs.com/team42/p/6883599.html