package practice;
public class string1 {
String ab="abcdefghijk";
String ac="shfkjashfasfh";
String aC="SHfkjashfasfh";
String abc="abcdef";
static String bb,bb1;
public static void main(String[] args){
string1 it1=new string1();
it1.CharAt();
it1.compare();
it1.content();
it1.getbyte();
}
public void CharAt(){
char mm=ab.charAt(5);
System.out.println("String ab=abcdefghijk");
System.out.println("ab.charAt(5)="+mm);
int code=ab.codePointAt(5);
int code1=ab.codePointAt(4);
int codebefore=ab.codePointBefore(5);
System.out.println("ab.codePointAt(4)="+code1);
System.out.println("ab.codePointAt(5)="+code);
System.out.println("ab.codePointBefore(5)="+codebefore);
int codepoint=ab.codePointCount(3, 6);
int codepoint1=ab.codePointCount(3, 5);
System.out.println("ab.codePointCount(3, 6)="+codepoint);
System.out.println("ab.codePointCount(3, 5)="+codepoint);
//为什么产生两个都是3???????
}
public void compare(){
int comp1=ab.compareTo(ac);
String AB="abcdefghijk";
String ABC="ABCDEFGHIJK";
System.out.println("comp1="+comp1);
//为什么会产生负数?????
int comp2=ab.compareToIgnoreCase(aC);
System.out.println("comp2="+comp2);
String concat=ab.concat(ac);
System.out.println("串接后的字符串="+concat);
if(ab.endsWith("k")){
System.out.println("ab是以k结束的");
}
else{System.out.println("ab是不以k结束的");}
if(AB.equals(ab)){
System.out.println("AB equals ab");
}
else{System.out.println("AB 不等于 ab");}
if(ab.equalsIgnoreCase(ABC)){
System.out.println("ab不记大小字母等于ABC");}
else{
System.out.println("ab不记大小字母不等于ABC");}
}
public void content(){
String abc="abcdef";
char qq[]={'d','b','c'};
if(ab.contains(abc)){
System.out.println("ab包含abc");
}
else {
System.out.println("ab不包含abc");
}
if(ab.contentEquals(abc)){
System.out.println("ab与abc相等");
}
else{System.out.println("ab与abc不相等");}
bb=ab.copyValueOf(qq);
System.out.println("ab与qq="+bb+"--"+ab);
bb1=ab.copyValueOf(qq,0,2);
System.out.println("ab与qq="+bb1);
}
public void getbyte(){
bb=ab.format(abc,aC );
char a[];
System.out.println("bb======="+bb);
byte ben[]=ab.getBytes();
System.out.println("ab.getBytes()======="+ben[1]+"===="+ben);
//ab.getChars(1, 3,a[3], 0);
int vc=ab.hashCode();
System.out.println("ab.hashCode()===="+vc);
int b1=ab.indexOf(1);
System.out.println("ab.indexOf(1)===="+b1);
int num=123456;
int b2=ab.indexOf(2);
System.out.println("ab.indexOf(2)===="+b2);
int b3=ab.indexOf(3);
System.out.println("ab.indexOf(3)===="+b3);
//怎么都是负1?????
int b4=ab.indexOf(2, 3);
System.out.println("ab.indexOf(1, 3)===="+b4);
int b5=ab.indexOf("bc");
System.out.println("ab.indexOf(bc)======="+b5);
}
}