Diffrence Between Object and Reference
Hi,
I will create ArrayList reference and Object after access the Method.. what is the diffrence betweem this two?
Coding :
(i)
ArrayList disList=null;
disList =oAction.onLoad();
(ii)
ArrayList disList = new ArrayList();
disList =oAction.onLoad();
Plz read above the Coding and reply the diffrence..
Thanking u,
A r eference points to an object.
Foo foo = new Foo();
We have created a Foo object. foo is a reference variable that holds a reference to that object. It "points to" the object.
jverda at 2007-7-29 14:52:47 >

> (i)
> ArrayList disList=null;
disList is a reference variable. We've set its value to null, meaning it doesn't point to any object.
> disList =oAction.onLoad();
Now disList's value is a reference to an object--the same object referred to by the result of onLoad.
> (ii)
>
> ArrayList disList = new ArrayList();
disList holds a reference to the newly created ArrayList.
> disList =oAction.onLoad();
Now disList points to a different ArrayList. Nothing points to the list we created in the previous statement.
jverda at 2007-7-29 14:52:47 >
