/Character包装类 public class test23 { public static void main ( String [] args ){ char ch = 'A' ; //使用构造方法 Character obj1 = new Character ( '中' ); //使用静态方法 Character obj2 = Character . valueOf ( ch ); //获取c
public class test23 {
public static void main(String[] args){
char ch='A';
//使用构造方法
Character obj1=new Character('中');
//使用静态方法
Character obj2=Character.valueOf(ch);
//获取char值
char zhong=obj1.charValue();
System.out.println(zhong);
int res=obj2.compareTo('B');
System.out.println(res);
String str=obj1.toString();
System.out.println(str.length());
}
}
运行结果