• Post Reply Bookmark Topic Watch Topic
  • New Topic

"new" keyword  RSS feed

 
eswar kumar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wht happens when we instantiate an object using "new" keyword (in heap,reference,constructor)?
 
Cyrus Serrano
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
in my opinion, when the new keyword is invoked, this mean you are creating an object and assigning a variable to reference on that object. Of course that object will eat up space in the computers memory like any other variable(primitives). Whenever you want to use that object, you can use the reference variable. When an object is instantiated, of course the constructor is inspected and initialize the objects attributes. This enforces consistency on creating objects.
Hope that helps..
Cyrus
[ November 18, 2003: Message edited by: Cyrus Serrano ]
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eswar,
In my opinion, there is a very good explanation of this in Bruce Eckel's book, Thinking in Java. If you haven't already looked at it, allow me to (highly) recommend it!
Good Luck,
Avi.
[ November 18, 2003: Message edited by: Avi Abrami ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!