package hvy;
public class hvy {
public static void main(String[] args) {
Character s=new Character('a');
Character c=new Character('A');
if(s.equals(c)) {
System.out.println("对象相等");
}else {
System.out.println("对象不相等"); }
Character n=Character.toLowerCase('a');
Character f=Character.toLowerCase('A');
if(n.equals(f)) {
System.out.println("对象相等");
}else {
System.out.println("对象不相等"); }
}
创建一个Charcter对象,通过equal()比较他是否相等; 之后将这两个对象分别转换为小写形式,再通过equal()方法来判断这两个对象是否相等?
最新推荐文章于 2022-10-15 23:21:28 发布