Меня удивляет, что геттеры членов height
и width
имеют return
типа double
, хотя они int
. Более того, метод setSize
с параметрами double имеет следующее определение:
/**
* Sets the size of this Dimension
object to
* the specified width and height in double precision.
* Note that if width
or height
* are larger than Integer.MAX_VALUE
, they will
* be reset to Integer.MAX_VALUE
.
*
* @param width the new width for the Dimension
object
* @param height the new height for the Dimension
object
*/
public void setSize(double width, double height) {
this.width = (int) Math.ceil(width);
this.height = (int) Math.ceil(height);
}
Пожалуйста, посмотрите на класс Dimension. В приведенном выше комментарии говорится, что значения не могут выходить за пределы Integer.MAX_VALUE. Почему?
Почему у нас есть double
между ними? Есть ли какая-то тонкая причина? Может ли кто-нибудь объяснить мне это? Извините за мою настойчивость!