Skip to content

Instantly share code, notes, and snippets.

@TyagiSoftTech
Created July 17, 2017 07:02
Show Gist options
  • Save TyagiSoftTech/1ec411a713eda6ce208fa7e8376411f6 to your computer and use it in GitHub Desktop.
Save TyagiSoftTech/1ec411a713eda6ce208fa7e8376411f6 to your computer and use it in GitHub Desktop.
class L
{
int i;
L(int i)
{
this.i=i;
}
}
class M
{
L param1;
int param2;
M(L param1, int param2)
{
this.param1=param1;
this.param2=param2;
}
public boolean equlas(Object o1)
{
return(o1 instanceof M && ((M)o1).param1 !=null &&
((M)o1).param1.i==param1.i && param2==((M)o1).param2);
}
}
public class Manager6
{
public static void main(String[] args)
{
L l1= new L(10);
L l2= null;
M m1 = new M(l1,21);
M m2 = new M(l1,21);
M m3 = new M(l2,21);
System.out.println(m1.equals(m2));
System.out.println(m2.equals(m3));
System.out.println(m1.equals(null));
System.out.println(m1.equals(l1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment