This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes new Operator purpose Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "new Operator purpose" Watch "new Operator purpose" New topic
Author

new Operator purpose

Mohammed Javeed Basha
Greenhorn

Joined: May 22, 2012
Posts: 9
What is the purpose of new operator in java rather than creating objects?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38441
    
  23
I presume you meant other than creating objects? Has it got another purpose? I thought that was it.
If you go through the Java™ Language Specification (JLS) contents with ctrl-f-new, this is the only “hit”. Have a look at it. In chapter 18 of the JLS, the word new only seems to appear thrice. Have a look at that, too.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

The "new" operator allocates memory (on the heap) for a new object and initializes the new object.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Mohammed Javeed Basha
Greenhorn

Joined: May 22, 2012
Posts: 9
Sorry for my english yes other than only, other than creating and allocating memory for objects
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38441
    
  23
As I said, I thought that was its only use. If you look for “new” as I said earlier, there do not appear to be any other uses for it.
Mohammed Javeed Basha
Greenhorn

Joined: May 22, 2012
Posts: 9
Thanks for all who replied
 
Consider Paul's rocket mass heater.
 
subject: new Operator purpose