This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

reference assigned to a expression  RSS feed

 
p sandeep
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi

my name sandeep

what is the realtime application and advantage " of assigning a reference to a expression " like this:

int height = new Rectangle().height

where rectangle is the class and height is a variable.


Is it right to implement the above one using " this() " so that it can call the present's class constructor right
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I can't really understand any of what you're asking here. In the specific case of new Rectangle().height, there's no point at all; the answer will always be zero. Surely you have something else a little more useful in mind here!

As to what this() has to do with it, and why this is posted in our "Threads and Synchronization" forum, I can't begin to guess.
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Agreed. This is *not* a threads question.

Unfortunately, I don't know where this question should be moved to, as it really needs clarification. Please clarify the question and resubmit it -- preferrably in a more appropriate forum.

Thanks,
Henry
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!