Size

Inheritance: java.lang.Object

public class Size

Class for describing width and height dimensions in some arbitrary unit.

Constructors

ConstructorDescription
Size(int width, int height)Create a new Size instance.

Methods

MethodDescription
getWidth()Get the width of the size.
getHeight()Get the height of the size.
equals(Object obj)Check if this size is equal to another size.
hashCode(){@inheritDoc}
toString()Return the size represented as a string with the format “WxH”

Size(int width, int height)

public Size(int width, int height)

Create a new Size instance.

Parameters:

ParameterTypeDescription
widthintThe width of the size
heightintThe height of the size

getWidth()

public int getWidth()

Get the width of the size.

Returns: int - width

getHeight()

public int getHeight()

Get the height of the size.

Returns: int - height

equals(Object obj)

public boolean equals(Object obj)

Check if this size is equal to another size.

Two sizes are equal if and only if both their widths and heights are equal.

A size object is never equal to any other type of object.

Parameters:

ParameterTypeDescription
objjava.lang.Object

Returns: boolean - true if the objects were equal, false otherwise

hashCode()

public int hashCode()

Returns: int

toString()

public String toString()

Return the size represented as a string with the format “WxH”

Returns: java.lang.String - string representation of the size