# CarLocation

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/CarLocation.java+class:androidx.car.app.model.CarLocation) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***


```
@CarProtocol
public final class CarLocation
```

<br />

*** ** * ** ***

Represents a geographical location with a latitude and a longitude.

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarLocation` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#create(android.location.Location)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/location/Location.html location)` Returns a new instance of a `https://developer.android.com/reference/androidx/car/app/model/CarLocation` with the same latitude and longitude contained in the given `https://developer.android.com/reference/android/location/Location.html`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarLocation` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#create(double,double)(double latitude, double longitude)` Returns a new instance of a `https://developer.android.com/reference/androidx/car/app/model/CarLocation`. |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `double` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#getLatitude()()` Returns the latitude of the location, in degrees. |
| `double` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#getLongitude()()` Returns the longitude of the location, in degrees. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#hashCode()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/CarLocation#toString()()` |

## Public methods

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static @NonNull CarLocation create(@NonNull Location location)
```

Returns a new instance of a `https://developer.android.com/reference/androidx/car/app/model/CarLocation` with the same latitude and longitude contained in the given `https://developer.android.com/reference/android/location/Location.html`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `location` is `null` |

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static @NonNull CarLocation create(double latitude, double longitude)
```

Returns a new instance of a `https://developer.android.com/reference/androidx/car/app/model/CarLocation`.

### equals

```
public boolean equals(@Nullable Object other)
```

### getLatitude

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public double getLatitude()
```

Returns the latitude of the location, in degrees.

### getLongitude

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public double getLongitude()
```

Returns the longitude of the location, in degrees.

### hashCode

```
public int hashCode()
```

### toString

```
public String toString()
```