• Post Reply Bookmark Topic Watch Topic
  • New Topic

plz hepl me out  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i m new to java.plz help me.i want to know what is difference between these two statments:----

suppose Add is a class.then

Add a;*****
and
Add a=new Add();******

i want to know about ** lines
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Add a; means you just create one reference variable for class Add.
now our 'a' points to some null reference.

Add a= new Add(); means we create object 'a' . now our obeject got memory.
that refernce points to memory(some address).
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first line does not instanciate an Add object.
It does not exist yet. So you won't be able to use it until you instanciate it (using the new keyword)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!