This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new Operator purpose

 
Mohammed Javeed Basha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of new operator in java rather than creating objects?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50225
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "new" operator allocates memory (on the heap) for a new object and initializes the new object.
 
Mohammed Javeed Basha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for my english yes other than only, other than creating and allocating memory for objects
 
Campbell Ritchie
Sheriff
Pie
Posts: 50225
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all who replied
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic