This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Simple Object Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple Object Question" Watch "Simple Object Question" New topic
Author

Simple Object Question

J. Ryan
Greenhorn

Joined: Jul 24, 2006
Posts: 21
I have a simple question about when memory is actually allocated. What is the difference between the following two code snippets?



and



Thanks.
[ June 30, 2007: Message edited by: J Ryan ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

No difference at all, actually. Instance variable initializers like your "= new Object()" are compiled into the constructors of the class.


[Jess in Action][AskingGoodQuestions]
J. Ryan
Greenhorn

Joined: Jul 24, 2006
Posts: 21
Thanks!
 
rocket mass heater kickstarter
 
subject: Simple Object Question