Most visited

Recently visited

Added in API level 24

MeasureUnit

public class MeasureUnit
extends Object implements Serializable

java.lang.Object
   ↳ android.icu.util.MeasureUnit
Known Direct Subclasses


诸如长度,质量,体积,货币等的单位。单位与数字量相结合以产生度量。 MeasureUnit对象是不可变的。 所有的子类都必须保证。 (但是,不鼓励子类化。)

也可以看看:

Summary

Fields

public static final MeasureUnit ACRE

面积单位为常量:英亩

public static final MeasureUnit ACRE_FOOT

单位体积的常量:英亩 - 英尺

public static final MeasureUnit AMPERE

电单位常数:安培

public static final MeasureUnit ARC_MINUTE

角度单位的常量:弧分

public static final MeasureUnit ARC_SECOND

角度单位的常量:弧秒

public static final MeasureUnit ASTRONOMICAL_UNIT

长度单位常量:天文单位

public static final MeasureUnit BIT

数字单位常量:位

public static final MeasureUnit BUSHEL

单位量的常量:蒲式耳

public static final MeasureUnit BYTE

数字单元常量:字节

public static final MeasureUnit CALORIE

能量单位常量:卡路里

public static final MeasureUnit CARAT

质量单位常量:克拉

public static final MeasureUnit CELSIUS

温度单位常数:摄氏度

public static final MeasureUnit CENTILITER

单位体积的常量:centiliter

public static final MeasureUnit CENTIMETER

长度单位常量:厘米

public static final MeasureUnit CUBIC_CENTIMETER

单位体积的常数:立方厘米

public static final MeasureUnit CUBIC_FOOT

单位体积的常量:立方英尺

public static final MeasureUnit CUBIC_INCH

单位体积的常数:立方英寸

public static final MeasureUnit CUBIC_KILOMETER

单位体积的常数:立方公里

public static final MeasureUnit CUBIC_METER

单位体积的常数:立方米

public static final MeasureUnit CUBIC_MILE

单位体积的常量:立方英里

public static final MeasureUnit CUBIC_YARD

单位体积的常数:立方码

public static final MeasureUnit CUP

体积单位常数:杯

public static final TimeUnit DAY

持续时间单位为常数:一天

public static final MeasureUnit DECILITER

单位体积的常量:分升

public static final MeasureUnit DECIMETER

长度单位的常量:分米

public static final MeasureUnit DEGREE

角度单位常数:度

public static final MeasureUnit FAHRENHEIT

温度单位常数:华氏度

public static final MeasureUnit FATHOM

长度单位的常数:fathom

public static final MeasureUnit FLUID_OUNCE

体积单位常数:流体盎司

public static final MeasureUnit FOODCALORIE

单位能量的常数:foodcalorie

public static final MeasureUnit FOOT

长度单位的常量:英尺

public static final MeasureUnit FURLONG

长度单位为常数:furlong

public static final MeasureUnit GALLON

单位体积的常量:加仑

public static final MeasureUnit GIGABIT

数字单位常量:千兆位

public static final MeasureUnit GIGABYTE

数字单位常量:千兆字节

public static final MeasureUnit GIGAHERTZ

频率单位常数:千兆赫

public static final MeasureUnit GIGAWATT

单位功率常数:千兆瓦

public static final MeasureUnit GRAM

单位质量的常数:克

public static final MeasureUnit G_FORCE

加速度单位常数:重力

public static final MeasureUnit HECTARE

面积单位为常数:公顷

public static final MeasureUnit HECTOLITER

单位体积的常量:hectoliter

public static final MeasureUnit HECTOPASCAL

压力单位常数:百帕斯卡

public static final MeasureUnit HERTZ

频率单位常数:赫兹

public static final MeasureUnit HORSEPOWER

功率单位常量:马力

public static final TimeUnit HOUR

持续时间单位为常数:小时

public static final MeasureUnit INCH

长度单位常数:英寸

public static final MeasureUnit INCH_HG

压力单位常数:英寸-Hg

public static final MeasureUnit JOULE

能量单位常数:焦耳

public static final MeasureUnit KARAT

单位比例的常量:克拉

public static final MeasureUnit KELVIN

温度单位常数:开尔文

public static final MeasureUnit KILOBIT

数字单位常数:kilobit

public static final MeasureUnit KILOBYTE

数字单位常量:千字节

public static final MeasureUnit KILOCALORIE

单位能量的常量:千卡

public static final MeasureUnit KILOGRAM

质量单位的常量:千克

public static final MeasureUnit KILOHERTZ

频率单位常数:千赫兹

public static final MeasureUnit KILOJOULE

单位能量的常量:千焦耳

public static final MeasureUnit KILOMETER

长度单位常量:公里

public static final MeasureUnit KILOMETER_PER_HOUR

速度单位常数:公里每小时

public static final MeasureUnit KILOWATT

单位功率常数:千瓦

public static final MeasureUnit KILOWATT_HOUR

单位能量的常量:千瓦小时

public static final MeasureUnit LIGHT_YEAR

长度单位常量:光年

public static final MeasureUnit LITER

单位体积的常量:升

public static final MeasureUnit LITER_PER_KILOMETER

单位消耗量的常数:每公里

public static final MeasureUnit LUX

灯光单位常数:勒克斯

public static final MeasureUnit MEGABIT

数字单位常量:兆位

public static final MeasureUnit MEGABYTE

数字单位常量:兆字节

public static final MeasureUnit MEGAHERTZ

频率单位常数:兆赫

public static final MeasureUnit MEGALITER

单位体积的常量:兆加仑

public static final MeasureUnit MEGAWATT

功率单位常数:兆瓦

public static final MeasureUnit METER

长度单位的常量:米

public static final MeasureUnit METER_PER_SECOND

速度单位的常量:米每秒

public static final MeasureUnit METER_PER_SECOND_SQUARED

加速度单位为常数:每秒平方米

public static final MeasureUnit METRIC_TON

质量单位的常量:公吨

public static final MeasureUnit MICROGRAM

质量单位的常数:微克

public static final MeasureUnit MICROMETER

长度单位常数:千分尺

public static final MeasureUnit MICROSECOND

单位持续时间的常量:微秒

public static final MeasureUnit MILE

长度单位的常量:英里

public static final MeasureUnit MILE_PER_GALLON

单位消耗量的常量:每加仑英里数

public static final MeasureUnit MILE_PER_HOUR

速度单位常数:每小时英里数

public static final MeasureUnit MILLIAMPERE

电单位常数:毫安

public static final MeasureUnit MILLIBAR

压力单位常数:毫巴

public static final MeasureUnit MILLIGRAM

质量单位的常量:毫克

public static final MeasureUnit MILLILITER

体积单位常数:毫升

public static final MeasureUnit MILLIMETER

长度单位常量:毫米

public static final MeasureUnit MILLIMETER_OF_MERCURY

压力单位常数:毫米汞柱

public static final MeasureUnit MILLISECOND

单位持续时间的常量:毫秒

public static final MeasureUnit MILLIWATT

功率单位常数:毫瓦

public static final TimeUnit MINUTE

持续时间单位为常数:分钟

public static final TimeUnit MONTH

持续时间单位的常量:月

public static final MeasureUnit NANOMETER

长度单位常数:纳米

public static final MeasureUnit NANOSECOND

单位持续时间的常量:纳秒

public static final MeasureUnit NAUTICAL_MILE

长度单位为常数:海里 - 英里

public static final MeasureUnit OHM

电单位常数:欧姆

public static final MeasureUnit OUNCE

质量单位的常量:盎司

public static final MeasureUnit OUNCE_TROY

质量单位的常量:盎司 - 特洛伊

public static final MeasureUnit PARSEC

长度单位的常量:parsec

public static final MeasureUnit PICOMETER

长度单位为常数:皮米计

public static final MeasureUnit PINT

单位体积的常量:品脱

public static final MeasureUnit POUND

质量单位的常量:磅

public static final MeasureUnit POUND_PER_SQUARE_INCH

压力单位常数:磅/平方英寸

public static final MeasureUnit QUART

单位体积的常量:夸脱

public static final MeasureUnit RADIAN

角度单位常数:弧度

public static final TimeUnit SECOND

持续时间单位为常数:秒

public static final MeasureUnit SQUARE_CENTIMETER

面积单位常数:平方厘米

public static final MeasureUnit SQUARE_FOOT

面积单位为常数:平方英尺

public static final MeasureUnit SQUARE_INCH

面积单位为常数:平方英寸

public static final MeasureUnit SQUARE_KILOMETER

面积单位不变:平方千米

public static final MeasureUnit SQUARE_METER

面积单位为常数:平方米

public static final MeasureUnit SQUARE_MILE

面积单位为常数:平方英里

public static final MeasureUnit SQUARE_YARD

面积单位为常数:平方码

public static final MeasureUnit STONE

单位质量常数:石头

public static final MeasureUnit TABLESPOON

单位体积的常量:大汤匙

public static final MeasureUnit TEASPOON

单位体积的常量:茶匙

public static final MeasureUnit TERABIT

数字单位常量:太比特

public static final MeasureUnit TERABYTE

数字单位常量:兆兆字节

public static final MeasureUnit TON

单位质量常数:吨

public static final MeasureUnit VOLT

电单位常数:伏特

public static final MeasureUnit WATT

功率单位的常数:瓦特

public static final TimeUnit WEEK

持续时间单位的常量:周

public static final MeasureUnit YARD

长度单位常数:码

public static final TimeUnit YEAR

持续时间单位为常数:年

Public methods

boolean equals(Object rhs)

指示其他某个对象是否“等于”这一个。

static Set<MeasureUnit> getAvailable()

获取所有可用的单位。

static Set<MeasureUnit> getAvailable(String type)

对于给定的类型,返回可用的单位。

static Set<String> getAvailableTypes()

获取所有可用单位的类型。

String getSubtype()

获取子类型,例如“foot”。

String getType()

获取类型,如“长度”

int hashCode()

返回对象的哈希码值。

String toString()

返回对象的字符串表示形式。

Inherited methods

From class java.lang.Object

Fields

ACRE

Added in API level 24
MeasureUnit ACRE

面积单位为常量:英亩

ACRE_FOOT

Added in API level 24
MeasureUnit ACRE_FOOT

单位体积的常量:英亩 - 英尺

AMPERE

Added in API level 24
MeasureUnit AMPERE

电单位常数:安培

ARC_MINUTE

Added in API level 24
MeasureUnit ARC_MINUTE

角度单位的常量:弧分

ARC_SECOND

Added in API level 24
MeasureUnit ARC_SECOND

角度单位的常量:弧秒

ASTRONOMICAL_UNIT

Added in API level 24
MeasureUnit ASTRONOMICAL_UNIT

长度单位常量:天文单位

BIT

Added in API level 24
MeasureUnit BIT

数字单位常量:位

BUSHEL

Added in API level 24
MeasureUnit BUSHEL

单位量的常量:蒲式耳

BYTE

Added in API level 24
MeasureUnit BYTE

数字单元常量:字节

CALORIE

Added in API level 24
MeasureUnit CALORIE

能量单位常量:卡路里

CARAT

Added in API level 24
MeasureUnit CARAT

质量单位常量:克拉

CELSIUS

Added in API level 24
MeasureUnit CELSIUS

温度单位常数:摄氏度

CENTILITER

Added in API level 24
MeasureUnit CENTILITER

单位体积的常量:centiliter

CENTIMETER

Added in API level 24
MeasureUnit CENTIMETER

长度单位常量:厘米

CUBIC_CENTIMETER

Added in API level 24
MeasureUnit CUBIC_CENTIMETER

单位体积的常数:立方厘米

CUBIC_FOOT

Added in API level 24
MeasureUnit CUBIC_FOOT

单位体积的常量:立方英尺

CUBIC_INCH

Added in API level 24
MeasureUnit CUBIC_INCH

单位体积的常数:立方英寸

CUBIC_KILOMETER

Added in API level 24
MeasureUnit CUBIC_KILOMETER

单位体积的常数:立方公里

CUBIC_METER

Added in API level 24
MeasureUnit CUBIC_METER

单位体积的常数:立方米

CUBIC_MILE

Added in API level 24
MeasureUnit CUBIC_MILE

单位体积的常量:立方英里

CUBIC_YARD

Added in API level 24
MeasureUnit CUBIC_YARD

单位体积的常数:立方码

CUP

Added in API level 24
MeasureUnit CUP

体积单位常数:杯

DAY

Added in API level 24
TimeUnit DAY

持续时间单位为常数:一天

DECILITER

Added in API level 24
MeasureUnit DECILITER

单位体积的常量:分升

DECIMETER

Added in API level 24
MeasureUnit DECIMETER

长度单位的常量:分米

DEGREE

Added in API level 24
MeasureUnit DEGREE

角度单位常数:度

FAHRENHEIT

Added in API level 24
MeasureUnit FAHRENHEIT

温度单位常数:华氏度

FATHOM

Added in API level 24
MeasureUnit FATHOM

长度单位的常数:fathom

FLUID_OUNCE

Added in API level 24
MeasureUnit FLUID_OUNCE

体积单位常数:流体盎司

FOODCALORIE

Added in API level 24
MeasureUnit FOODCALORIE

单位能量的常数:foodcalorie

FOOT

Added in API level 24
MeasureUnit FOOT

长度单位的常量:英尺

FURLONG

Added in API level 24
MeasureUnit FURLONG

长度单位为常数:furlong

GALLON

Added in API level 24
MeasureUnit GALLON

单位体积的常量:加仑

GIGABIT

Added in API level 24
MeasureUnit GIGABIT

数字单位常量:千兆位

GIGABYTE

Added in API level 24
MeasureUnit GIGABYTE

数字单位常量:千兆字节

GIGAHERTZ

Added in API level 24
MeasureUnit GIGAHERTZ

频率单位常数:千兆赫

GIGAWATT

Added in API level 24
MeasureUnit GIGAWATT

单位功率常数:千兆瓦

GRAM

Added in API level 24
MeasureUnit GRAM

单位质量的常数:克

G_FORCE

Added in API level 24
MeasureUnit G_FORCE

加速度单位常数:重力

HECTARE

Added in API level 24
MeasureUnit HECTARE

面积单位为常数:公顷

HECTOLITER

Added in API level 24
MeasureUnit HECTOLITER

单位体积的常量:hectoliter

HECTOPASCAL

Added in API level 24
MeasureUnit HECTOPASCAL

压力单位常数:百帕斯卡

HERTZ

Added in API level 24
MeasureUnit HERTZ

频率单位常数:赫兹

HORSEPOWER

Added in API level 24
MeasureUnit HORSEPOWER

功率单位常量:马力

HOUR

Added in API level 24
TimeUnit HOUR

持续时间单位为常数:小时

INCH

Added in API level 24
MeasureUnit INCH

长度单位常数:英寸

INCH_HG

Added in API level 24
MeasureUnit INCH_HG

压力单位常数:英寸-Hg

JOULE

Added in API level 24
MeasureUnit JOULE

能量单位常数:焦耳

KARAT

Added in API level 24
MeasureUnit KARAT

单位比例的常量:克拉

KELVIN

Added in API level 24
MeasureUnit KELVIN

温度单位常数:开尔文

KILOBIT

Added in API level 24
MeasureUnit KILOBIT

数字单位常数:kilobit

KILOBYTE

Added in API level 24
MeasureUnit KILOBYTE

数字单位常量:千字节

KILOCALORIE

Added in API level 24
MeasureUnit KILOCALORIE

单位能量的常量:千卡

KILOGRAM

Added in API level 24
MeasureUnit KILOGRAM

质量单位的常量:千克

KILOHERTZ

Added in API level 24
MeasureUnit KILOHERTZ

频率单位常数:千赫兹

KILOJOULE

Added in API level 24
MeasureUnit KILOJOULE

单位能量的常量:千焦耳

KILOMETER

Added in API level 24
MeasureUnit KILOMETER

长度单位常量:公里

KILOMETER_PER_HOUR

Added in API level 24
MeasureUnit KILOMETER_PER_HOUR

速度单位常数:公里每小时

KILOWATT

Added in API level 24
MeasureUnit KILOWATT

单位功率常数:千瓦

KILOWATT_HOUR

Added in API level 24
MeasureUnit KILOWATT_HOUR

单位能量的常量:千瓦小时

LIGHT_YEAR

Added in API level 24
MeasureUnit LIGHT_YEAR

长度单位常量:光年

LITER

Added in API level 24
MeasureUnit LITER

单位体积的常量:升

LITER_PER_KILOMETER

Added in API level 24
MeasureUnit LITER_PER_KILOMETER

单位消耗量的常数:每公里

LUX

Added in API level 24
MeasureUnit LUX

灯光单位常数:勒克斯

MEGABIT

Added in API level 24
MeasureUnit MEGABIT

数字单位常量:兆位

MEGABYTE

Added in API level 24
MeasureUnit MEGABYTE

数字单位常量:兆字节

MEGAHERTZ

Added in API level 24
MeasureUnit MEGAHERTZ

频率单位常数:兆赫

MEGALITER

Added in API level 24
MeasureUnit MEGALITER

单位体积的常量:兆加仑

MEGAWATT

Added in API level 24
MeasureUnit MEGAWATT

功率单位常数:兆瓦

METER

Added in API level 24
MeasureUnit METER

长度单位的常量:米

METER_PER_SECOND

Added in API level 24
MeasureUnit METER_PER_SECOND

速度单位的常量:米每秒

METER_PER_SECOND_SQUARED

Added in API level 24
MeasureUnit METER_PER_SECOND_SQUARED

加速度单位为常数:每秒平方米

METRIC_TON

Added in API level 24
MeasureUnit METRIC_TON

质量单位的常量:公吨

MICROGRAM

Added in API level 24
MeasureUnit MICROGRAM

质量单位的常数:微克

MICROMETER

Added in API level 24
MeasureUnit MICROMETER

长度单位常数:千分尺

MICROSECOND

Added in API level 24
MeasureUnit MICROSECOND

单位持续时间的常量:微秒

MILE

Added in API level 24
MeasureUnit MILE

长度单位的常量:英里

MILE_PER_GALLON

Added in API level 24
MeasureUnit MILE_PER_GALLON

单位消耗量的常量:每加仑英里数

MILE_PER_HOUR

Added in API level 24
MeasureUnit MILE_PER_HOUR

速度单位常数:每小时英里数

MILLIAMPERE

Added in API level 24
MeasureUnit MILLIAMPERE

电单位常数:毫安

MILLIBAR

Added in API level 24
MeasureUnit MILLIBAR

压力单位常数:毫巴

MILLIGRAM

Added in API level 24
MeasureUnit MILLIGRAM

质量单位的常量:毫克

MILLILITER

Added in API level 24
MeasureUnit MILLILITER

体积单位常数:毫升

MILLIMETER

Added in API level 24
MeasureUnit MILLIMETER

长度单位常量:毫米

MILLIMETER_OF_MERCURY

Added in API level 24
MeasureUnit MILLIMETER_OF_MERCURY

压力单位常数:毫米汞柱

MILLISECOND

Added in API level 24
MeasureUnit MILLISECOND

单位持续时间的常量:毫秒

MILLIWATT

Added in API level 24
MeasureUnit MILLIWATT

功率单位常数:毫瓦

MINUTE

Added in API level 24
TimeUnit MINUTE

持续时间单位为常数:分钟

MONTH

Added in API level 24
TimeUnit MONTH

持续时间单位的常量:月

NANOMETER

Added in API level 24
MeasureUnit NANOMETER

长度单位常数:纳米

NANOSECOND

Added in API level 24
MeasureUnit NANOSECOND

单位持续时间的常量:纳秒

NAUTICAL_MILE

Added in API level 24
MeasureUnit NAUTICAL_MILE

长度单位为常数:海里 - 英里

OHM

Added in API level 24
MeasureUnit OHM

电单位常数:欧姆

OUNCE

Added in API level 24
MeasureUnit OUNCE

质量单位的常量:盎司

OUNCE_TROY

Added in API level 24
MeasureUnit OUNCE_TROY

质量单位的常量:盎司 - 特洛伊

PARSEC

Added in API level 24
MeasureUnit PARSEC

长度单位的常量:parsec

PICOMETER

Added in API level 24
MeasureUnit PICOMETER

长度单位为常数:皮米计

PINT

Added in API level 24
MeasureUnit PINT

单位体积的常量:品脱

POUND

Added in API level 24
MeasureUnit POUND

质量单位的常量:磅

POUND_PER_SQUARE_INCH

Added in API level 24
MeasureUnit POUND_PER_SQUARE_INCH

压力单位常数:磅/平方英寸

QUART

Added in API level 24
MeasureUnit QUART

单位体积的常量:夸脱

RADIAN

Added in API level 24
MeasureUnit RADIAN

角度单位常数:弧度

SECOND

Added in API level 24
TimeUnit SECOND

持续时间单位为常数:秒

SQUARE_CENTIMETER

Added in API level 24
MeasureUnit SQUARE_CENTIMETER

面积单位常数:平方厘米

SQUARE_FOOT

Added in API level 24
MeasureUnit SQUARE_FOOT

面积单位为常数:平方英尺

SQUARE_INCH

Added in API level 24
MeasureUnit SQUARE_INCH

面积单位为常数:平方英寸

SQUARE_KILOMETER

Added in API level 24
MeasureUnit SQUARE_KILOMETER

面积单位不变:平方千米

SQUARE_METER

Added in API level 24
MeasureUnit SQUARE_METER

面积单位为常数:平方米

SQUARE_MILE

Added in API level 24
MeasureUnit SQUARE_MILE

面积单位为常数:平方英里

SQUARE_YARD

Added in API level 24
MeasureUnit SQUARE_YARD

面积单位为常数:平方码

STONE

Added in API level 24
MeasureUnit STONE

单位质量常数:石头

TABLESPOON

Added in API level 24
MeasureUnit TABLESPOON

单位体积的常量:大汤匙

TEASPOON

Added in API level 24
MeasureUnit TEASPOON

单位体积的常量:茶匙

TERABIT

Added in API level 24
MeasureUnit TERABIT

数字单位常量:太比特

TERABYTE

Added in API level 24
MeasureUnit TERABYTE

数字单位常量:兆兆字节

TON

Added in API level 24
MeasureUnit TON

单位质量常数:吨

VOLT

Added in API level 24
MeasureUnit VOLT

电单位常数:伏特

WATT

Added in API level 24
MeasureUnit WATT

功率单位的常数:瓦特

WEEK

Added in API level 24
TimeUnit WEEK

持续时间单位的常量:周

YARD

Added in API level 24
MeasureUnit YARD

长度单位常数:码

YEAR

Added in API level 24
TimeUnit YEAR

持续时间单位为常数:年

Public methods

equals

Added in API level 24
boolean equals (Object rhs)

指示其他某个对象是否“等于”这一个。

equals方法在非空对象引用上实现等价关系:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

对于类Objectequals方法实现了对象上最可能的等价关系; 也就是说,对于任何非空参考值xy ,当且仅当xy引用同一对象( x == y的值为true )时,此方法返回true

请注意,无论何时覆盖此方法,通常都必须覆盖 hashCode方法,以便维护 hashCode方法的一般合同,该方法声明等同对象必须具有相同的哈希代码。

Parameters
rhs Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

getAvailable

Added in API level 24
Set<MeasureUnit> getAvailable ()

获取所有可用的单位。 返回的集是不可修改的。

Returns
Set<MeasureUnit>

getAvailable

Added in API level 24
Set<MeasureUnit> getAvailable (String type)

对于给定的类型,返回可用的单位。

Parameters
type String: the type
Returns
Set<MeasureUnit> the available units for type. Returned set is unmodifiable.

getAvailableTypes

Added in API level 24
Set<String> getAvailableTypes ()

获取所有可用单位的类型。 返回的集是不可修改的。

Returns
Set<String>

getSubtype

Added in API level 24
String getSubtype ()

获取子类型,例如“foot”。

Returns
String

getType

Added in API level 24
String getType ()

获取类型,如“长度”

Returns
String

hashCode

Added in API level 24
int hashCode ()

返回对象的哈希码值。 为了散列表的好处而支持此方法,例如由HashMap提供的HashMap

一般合同 hashCode是:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

尽可能合理实用,类Object定义的hashCode方法确实为不同的对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java TM编程语言不需要此实现技术。)

Returns
int a hash code value for this object.

toString

Added in API level 24
String toString ()

返回对象的字符串表示形式。 一般来说, toString方法会返回一个“文本表示”该对象的字符串。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。

ObjecttoString方法返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示形式。 换句话说,这个方法返回一个字符串,其值等于:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

Hooray!