Skip to content

Commit 24ce457

Browse files
committed
Update Arr
1 parent 306ca96 commit 24ce457

File tree

1 file changed

+17
-7
lines changed
  • non-primitive-data-types/basic/Array

1 file changed

+17
-7
lines changed

Diff for: non-primitive-data-types/basic/Array/README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ An array in Java is a data structure that can hold multiple values of the same t
3838

3939
---
4040

41-
# Static Methods
41+
## Static Methods
42+
43+
```java
44+
int arr[] = {20, 41, 3, 23}; // Use this as an example
45+
46+
int arr_2[] = new int[3]; // Empty array
47+
```
4248

4349
| **Method** | **Description** | **Return Type** | **Example** |
4450
|---------------------------------------------|----------------------------------------------------------------------------|--------------------|-------------------------------------------------|
45-
| `copyOf(int[] original, int newLength)` | Copies the specified array, truncating or padding with `0` or `null`. | `int[]` | `Arrays.copyOf(arr, 10);` |
51+
| `copyOf(int[] original, int newLength)` | Copies the specified array, truncating or padding with `0` or `null`. | `int[]` | `Arrays.copyOf(arr, 2);` |
4652
| `fill(int[] array, int val)` | Fills the array with the specified value. | `void` | `Arrays.fill(arr, 5);` |
4753
| `equals(int[] a, int[] b)` | Compares two arrays for equality. | `boolean` | `Arrays.equals(arr1, arr2);` |
4854
| `sort(int[] a)` | Sorts the specified array in ascending order. | `void` | `Arrays.sort(arr);` |
@@ -57,11 +63,15 @@ An array in Java is a data structure that can hold multiple values of the same t
5763

5864
## Instance Methods
5965

60-
| **Method** | **Description** | **Return Type** | **Example** |
61-
|-------------|------------------------------------------|--------------------|----------------------------------------------|
62-
| `length` | Returns the length of the array. | `int` | `arr.length;` |
63-
| `clone()` | Creates a copy of the array. | `Object` | `arr.clone();` |
64-
| `hashCode()`| Returns a hash code value for the array. | `int` | `arr.hashCode();` |
66+
```java
67+
int arr[] = {20, 41, 3, 23}; // Use this as an example
68+
```
69+
70+
| **Method** | **Description** | **Return Type** | **Example** | **Retuwn Value** |
71+
|-------------|------------------------------------------|--------------------|----------------------------------------------|------------------|
72+
| `length` | Returns the length of the array. | `int` | `arr.length;` |`4` (Length of the array)|
73+
| `clone()` | Creates a copy of the array. | `Object` | `arr.clone();` |`{20, 41, 3, 23}` (A new array)|
74+
| `hashCode()`| Returns a hash code value for the array. | `int` | `arr.hashCode();` | An integer (e.g : `12345678`)|
6575

6676
---
6777

0 commit comments

Comments
 (0)