In the following program how y.link is null?
class Holder
{
int value = 1;
Holder link;
public Holder(int val){ this.value = val; }
public static void main(String[] args)
{
final Holder a = new Holder(5);
Holder b = new Holder(10);
a.link = b;
b.link = setIt(a, b);
System.out.println(a.link.value+" "+b.link.value);
}
public static Holder setIt(final Holder x, final Holder y)
{
x.link = y.link;
return x;
}
}
Can somebody explain me please?
About Question com.enthuware.ets.scjp.v6.2.54 :
Moderator: admin
Re: About Question com.enthuware.ets.scjp.v6.2.54 :
Because ,
(a.link or x.link) and (b.link or y.link) are just Holder objects that
are not instantiated anywhere in the code. So they are null.
Hope that helps
Good Luck!
(a.link or x.link) and (b.link or y.link) are just Holder objects that
are not instantiated anywhere in the code. So they are null.
Hope that helps
Good Luck!
Who is online
Users browsing this forum: No registered users and 208 guests