R4-1
class MyDate{ int year; int month; int day; MyDate(int year,int month,int day){ this.year=year; this.month=month; this.day=day; } } public class Main{ public static void main(String args[]){ MyDate md1=new MyDate(2009,2,10); MyDate md2=new MyDate(2009,2,10); if(md1==md2) System.out.println("md1==md2"); else System.out.println("md1!=md2"); if(md1.equals(md2)) System.out.println("md1 is equla to md2"); else System.out.println("md1 is not equal to md2"); } }
运行上述代码,写出其运行结果:
md1!=md2
md1 is not equal to md2
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)