Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions) Summary: [Methods](https://developer.android.com/reference/android/health/connect/datatypes/units/Length#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/health/connect/datatypes/units/Length#inhmethods)

# Length

*** ** * ** ***


`
public

final

class
Length
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/android/health/connect/datatypes/units/Length>


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.health.connect.datatypes.units.Length |

<br />

*** ** * ** ***

Represents a unit of length. Supported units: meters

## Summary

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/health/connect/datatypes/units/Length#compareTo(android.health.connect.datatypes.units.Length)(https://developer.android.com/reference/android/health/connect/datatypes/units/Length other) ` Compares this object with the specified object for order. |
| ` boolean` | ` https://developer.android.com/reference/android/health/connect/datatypes/units/Length#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object object) ` Indicates whether some other object is "equal to" this one. |
| ` static https://developer.android.com/reference/android/health/connect/datatypes/units/Length` | ` https://developer.android.com/reference/android/health/connect/datatypes/units/Length#fromMeters(double)(double value) ` Creates a Length object with the specified value in meters. |
| ` double` | ` https://developer.android.com/reference/android/health/connect/datatypes/units/Length#getInMeters()() ` Returns length in meters |
| ` int` | ` https://developer.android.com/reference/android/health/connect/datatypes/units/Length#hashCode()() ` Returns a hash code value for the object. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/health/connect/datatypes/units/Length#toString()() ` Returns a string representation of the object. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/lang/Comparable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/android/health/connect/datatypes/units/Length o) ` Compares this object with the specified object for order. | ||

## Public methods

### compareTo

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions)

```
public int compareTo (Length other)
```

Compares this object with the specified object for order. Returns a negative integer, zero,
or a positive integer as this object is less than, equal to, or greater than the specified
object.

<br />

| Parameters ||
|---|---|
| `other` | `Length`: the object to be compared. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassCastException` | if the specified object's type prevents it from being compared to this object. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the specified object is null |

### equals

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object object)
```

Indicates whether some other object is "equal to" this one.

<br />

| Parameters ||
|---|---|
| `object` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the object argument; `false` otherwise. <br /> |

### fromMeters

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions)

```
public static Length fromMeters (double value)
```

Creates a Length object with the specified value in meters.

<br />

| Parameters ||
|---|---|
| `value` | `double`: value to be set as meters. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/units/Length` | This value cannot be `null`. <br /> |

### getInMeters

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions)

```
public double getInMeters ()
```

Returns length in meters

<br />

| Returns ||
|---|---|
| `double` | <br /> |

### hashCode

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code value for the object.

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### toString

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |