- All Implemented Interfaces:
Serializable,Comparable<Length.Unit>,Constable
- Enclosing class:
- Length
Represents a given length unit.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresents a cable: ≙ 185.3184 m.Represents a fathom: ≙ 1.853184 m.Represents a foot: ≙ 0.3048 m.Represents an inch: ≙ 0.0254 m.Represents a kilometer: ≙ 1,000 m.Represents a meter.Represents a statute mile: ≙ 1,609.344 m.Represents a nautical mile: ≙ 1,853.184 m.Represents a yard: ≙ 0.9144 m. -
Method Summary
Modifier and TypeMethodDescriptiondoubleconvert(double length, Length.Unit sourceUnit) Convert the given length value of the givensourceUnitinto a length value ofthislength unit.static Length.UnitReturns the enum constant of this class with the specified name.static Length.Unit[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
METER
Represents a meter. -
KILOMETER
Represents a kilometer: ≙ 1,000 m. -
INCH
Represents an inch: ≙ 0.0254 m. -
FOOT
Represents a foot: ≙ 0.3048 m. -
YARD
Represents a yard: ≙ 0.9144 m. -
MILE
Represents a statute mile: ≙ 1,609.344 m. -
FATHOM
Represents a fathom: ≙ 1.853184 m. -
CABLE
Represents a cable: ≙ 185.3184 m. -
NAUTICAL_MILE
Represents a nautical mile: ≙ 1,853.184 m.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
convert
Convert the given length value of the givensourceUnitinto a length value ofthislength unit. The given example converts 3 inches into yards.final double yards = YARD.convert(3, INCH);- Parameters:
length- the length valuesourceUnit- the source length unit- Returns:
- the speed value of
thislength unit
-