In the code below why foo2 is null when printing its data at system.out.print?
public class Helper {
public void shadowCopy(Foo foo1, Foo foo2){
foo2 = foo1;
}
public static void main(String[] args) {
Helper h = new Helper();
Foo foo1 = new Foo(50);
Foo foo2= null;
h.shadowCopy(foo1, foo2);
System.out.println(foo2.data);// why java.lang.NullPointerException?
}
public static class Foo {
public int data=0;
public Foo(int data){
this.data = data;
}
}
}