• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rectangle constructor question  RSS feed

 
Ryan Bishop
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?

 
Paweł Baczyński
Bartender
Posts: 2077
44
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.
 
Campbell Ritchie
Marshal
Posts: 56527
172
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!