# ImmutableByteArray

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/ImmutableByteArray.java+class:androidx.media3.test.utils.ImmutableByteArray)

*** ** * ** ***

<br />

```
@UnstableApi
public final class ImmutableByteArray
```

<br />

*** ** * ** ***

`byte` version of `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/ImmutableIntArray.html`.

This avoids the boxing/un-boxing costs of `ImmutableList<Byte>` and offers more ergonomic integration with APIs that expect a `byte[]`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` Builder for `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` instances. |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#concat(androidx.media3.test.utils.ImmutableByteArray...)(ImmutableByteArray[] arrays)` Returns an instance containing the concatenated contents of `arrays`. |
| `static byte[]` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#concatToArray(androidx.media3.test.utils.ImmutableByteArray...)(ImmutableByteArray[] arrays)` Returns a `byte[]` containing the concatenated contents of `arrays`. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#copyOf(java.util.Collection<java.lang.Byte>)(https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/java/lang/Byte.html> collection)` Returns an instance backed by a copy of `collection`. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#copyOf(byte[])(byte[] values)` Returns an instance backed by a copy of `values`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `byte` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#get(int)(int i)` Returns the `byte` at index `i`. |
| `int` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#isEmpty()()` Returns true if this array contains no elements. |
| `int` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#length()()` Returns the number of elements in this array. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#of()()` Returns an empty instance. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#ofHexString(java.lang.String)(https://developer.android.com/reference/java/lang/String.html hexString)` Returns an instance containing the bytes encoded in `hexString`. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#ofUnsigned(long,long...)(long value1, long[] otherValues)` Returns an instance containing the provided `long` values converted to `byte` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#subArray(int,int)(int startIndex, int endIndex)` Returns a new `byte[]` containing the elements from this instance between indexes ` startIndex` (inclusive) and `endIndex` (exclusive). |
| `byte[]` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#toArray()()` Returns a new `byte[]` containing the same elements as this instance. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray#toString()()` |

## Public methods

### concat

```
public static ImmutableByteArray concat(ImmutableByteArray[] arrays)
```

Returns an instance containing the concatenated contents of `arrays`.

### concatToArray

```
public static byte[] concatToArray(ImmutableByteArray[] arrays)
```

Returns a `byte[]` containing the concatenated contents of `arrays`.

### copyOf

```
public static ImmutableByteArray copyOf(Collection<Byte> collection)
```

Returns an instance backed by a copy of `collection`.

### copyOf

```
public static ImmutableByteArray copyOf(byte[] values)
```

Returns an instance backed by a copy of `values`.

### equals

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

### get

```
public byte get(int i)
```

Returns the `byte` at index `i`.

### hashCode

```
public int hashCode()
```

### isEmpty

```
public boolean isEmpty()
```

Returns true if this array contains no elements.

### length

```
public int length()
```

Returns the number of elements in this array.

### of

```
public static ImmutableByteArray of()
```

Returns an empty instance.

### ofHexString

```
public static ImmutableByteArray ofHexString(String hexString)
```

Returns an instance containing the bytes encoded in `hexString`.

### ofUnsigned

```
public static ImmutableByteArray ofUnsigned(long value1, long[] otherValues)
```

Returns an instance containing the provided `long` values converted to `byte` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)`.

### subArray

```
public ImmutableByteArray subArray(int startIndex, int endIndex)
```

Returns a new `byte[]` containing the elements from this instance between indexes ` startIndex` (inclusive) and `endIndex` (exclusive).

### toArray

```
public byte[] toArray()
```

Returns a new `byte[]` containing the same elements as this instance.

### toString

```
public String toString()
```