Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.awt.Dimension  RSS feed

 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does the Dimension class store int's and yet return doubles from getHeight() and getWidth() ?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm no authority on this, but I would guess that the cover accessor methods return double as a convenience, seeing as the int fields are public.
 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Darryl, that sounds logical.
 
Stephan van Hulst
Saloon Keeper
Posts: 7006
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a convenience for what, though?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Direct use in floating point arithmetic without having to cast to double, perhaps?

edit It's more likely that it's just a result of retrofitting Dimension to extend abstract class Dimension2D which, unlike the other '2D' classes (Arc2D / CubicCurve2D / Ellipse2D / Line2D / Point2D / QuadCurve2D / Rectangle2D / RoundRectangle2D), doesn't have Double and Float implementations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!