In JAVA
As I know it has two way to pass object (by reference) to
Anothor Class or Object
Code:
first >
class Test{
JList list;
Test(){
list = new JList();
new Test2(list);
}
}
class Test2{
JList list;
Test2(JList list){
this.list=list;
list.doAnyThingYouWant();
}
}
I call it that "pass via argument"
***************************************
and second >
class Test{
public static JList list;
Test(){
list = new JList();
new Test2();
}
}
class Test2{
Test2(){
Test.list.doAnyThingYouWant();
}
}
I call it that "pass via static variable"
first or second is more efficiency ?
and is it diffrence if it is ,how ?
Thanks in advance!