Java编程入门与应用 P160——演示——Character
/**
* Java编程入门与应用 P160——演示——Character
*/
public class use_Character {
public static void main(String[] args) {
//构建Character类的实例
Character character = new Character('A');
//比较
int result1 = character.compareTo(new Character('A'));
System.out.println("result1的比较结果:" + result1);
int result2 = character.compareTo(new Character('B'));
System.out.println("result2的比较结果:" + result2);
int result3 = character.compareTo(new Character('C'));
System.out.println("result3的比较结果:" + result3);
}
}
结果:
result1的比较结果:0
result2的比较结果:-1
result3的比较结果:-2
进程已结束,退出代码为 0
感谢观看
再次感谢~