• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rectangle constructor question  RSS feed

 
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code is from the Oracle tutorials. Can someone explain line 6 to me? Is
the programmer able to do that because Rectangle() encapsulates Rectangle(int x, int y, int width, int height)?
If that's the case, what is the point of other Rectangle constructors if Rectangle() subsumes them?

 
Bartender
Posts: 2155
46
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ryan Bishop wrote:If that's the case, what is the point of other Rectangle constructors if Rectangle() subsumes them?


It is just for the convinience of programmers using this class.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It's really starting to bother me how stupid I am.
 
Marshal
Posts: 58470
178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing stupid about the question.
That exmple is in the tutorials to show how you can have multiple constructors in an object.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!