About Question com.enthuware.ets.scjp.v6.2.54 :
Posted: Wed Jul 27, 2011 2:50 pm
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?
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?