@@ -38,11 +38,17 @@ An array in Java is a data structure that can hold multiple values of the same t
38
38
39
39
---
40
40
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
+ ```
42
48
43
49
| ** Method** | ** Description** | ** Return Type** | ** Example** |
44
50
| ---------------------------------------------| ----------------------------------------------------------------------------| --------------------| -------------------------------------------------|
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 ); ` |
46
52
| ` fill(int[] array, int val) ` | Fills the array with the specified value. | ` void ` | ` Arrays.fill(arr, 5); ` |
47
53
| ` equals(int[] a, int[] b) ` | Compares two arrays for equality. | ` boolean ` | ` Arrays.equals(arr1, arr2); ` |
48
54
| ` 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
57
63
58
64
## Instance Methods
59
65
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 ` )|
65
75
66
76
---
67
77
0 commit comments