62,621
社区成员
发帖
与我相关
我的任务
分享public class AAA_1
{
public static void main(String[] args)
{
B<String> b1=new B<String>("absdf");
B<String> b2=new B<String>("absdf");
System.out.println(b1.equals(b2));
int a=300;
B<Integer> b3=new B<Integer>(a);
B<Integer> b4=new B<Integer>(a);
System.out.println(b3.equals(b4));
}
}
class B<L>
{
private L i;
B(L i)
{
this.i=i;
}
public boolean equals(B<L> b)
{
System.out.println(this.i.hashCode()+"\t"+b.i.hashCode());
if(this.i==b.i)
return true;
else
return false;
}
}
public boolean equals(B<L> b)
{
System.out.println(this.i.hashCode()+"\t"+b.i.hashCode());
//if(this.i==b.i)
if(this.i.equals(b.i))
return true;
else
return false;
}