Skip to content

Commit 84b5ea0

Browse files
committed
README Update of Arrays
1 parent e5cc233 commit 84b5ea0

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,86 @@ Note : The Code Content will be available on this [link](https://github.com/ackw
10241024

10251025
Note : The Code is available on this [link](https://github.com/ackwolver335/Java-Coder/blob/main/arr_mds.java)
10261026

1027+
## Multidimensional Arrays
1028+
1029+
Multidimensional Arrays can be defined in simple words as array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order).
1030+
1031+
Syntax Code :
1032+
1033+
```java
1034+
import java.util.Arrays;
1035+
int[][] twoD_arr = new int[2][3]; // 2 Rows and 3 Columns
1036+
int[][][] threeD_arr = new int[2][2][2] // 2 Rows and 2 Columns and 2 z-directional flow
1037+
1038+
// Accessing Elements
1039+
System.out.println("Array's First Row " + Arrays.toString(arr[0]));
1040+
```
1041+
1042+
Note : At the Basic level of concept the code [link](https://github.com/ackwolver335/Java-Coder/blob/main/arr_multi.java) is here.
1043+
1044+
## Categories of Arrays
1045+
1046+
- **Jagged Arrays** : A jagged array is an array of arrays such that member arrays can be of different sizes, i.e., we can create a 2-D array but with a variable number of columns in each row. These types of arrays are also known as Jagged arrays.
1047+
1048+
Syntax Code :
1049+
1050+
```java
1051+
int arr[][] = new int[3][]; // initializing array first
1052+
arr[0] = new int[2]; // Number of elements in first row
1053+
arr[1] = new int[3]; // Number of elements in second row
1054+
arr[2] = new int[2]; // Number of elements in third row
1055+
```
1056+
1057+
Code Link : [Click_me](https://github.com/ackwolver335/Java-Coder/blob/main/arr_jagg.java)
1058+
1059+
- **Final Arrays** : The array arr is declared as final, but the elements of an array are changed without any problem. Arrays are objects and object variables are always references in Java. So, when we declare an object variable as final, it means that the variable cannot be changed to refer to anything else.
1060+
1061+
Syntax Code :
1062+
1063+
```java
1064+
final int arr[] = new int[3];
1065+
```
1066+
1067+
Code Link : [Click_me](https://github.com/ackwolver335/Java-Coder/blob/main/arr_final.java)
1068+
1069+
- **Reflect Arrays** : The Array class in java.lang.reflect package is a part of the Java Reflection. This class provides static methods to create and access Java arrays dynamically. It is a final class, which means it can’t be instantiated or changed. Only the methods of this class can be used by the class name itself.
1070+
1071+
Syntax Code :
1072+
1073+
```java
1074+
import java.lang.reflect.Array;
1075+
import java.util.Arrays;
1076+
int size1 = 3;
1077+
int[] array_name = (int[])Array.newInstance(int.class,size1);
1078+
1079+
Array.setInt(array_name,0,12); // For Setting Element value
1080+
System.out.println("Element of the array : " + Arrays.toString(Array.getInt(array_name,0)));
1081+
```
1082+
1083+
Code Link : [Click_me](https://github.com/ackwolver335/Java-Coder/blob/main/arr_reflect.java)
1084+
1085+
### Methods of Reflect Arrays
1086+
1087+
| **Method Name** | **Uses** |
1088+
| :-------------- | :------- |
1089+
| **get()** | ***Used to get a particular array's element with the help of its index*** |
1090+
| **getBoolean()** | ***Used to get a particular array's element with specified index, if the array is of Boolean Data Type*** |
1091+
| **getByte()** | ***Used to get a particular element of array as per specified index, if the array is of Byte Data Type*** |
1092+
| **getChar()** | ***Used to get a particular element with its index, if the array is of Char Data Type*** |
1093+
| **getDouble()** | ***Used to get a particular element with its index, if the array is of Double Data Type*** |
1094+
| **getFloat()** | ***Used to get a particular element with its index, if the array is of Float Data Type*** |
1095+
| **getInt()** | ***Used to get a particular element with its index, if the array is of Int Data Type*** |
1096+
| **getShort()** | ***Used to get a particular element with its index, if the array is of Short Data Type*** |
1097+
| **newInstance()** | ***Used to create a new array with a specified component type and length*** |
1098+
| **set()** | ***Used to change the value of a particular element with its index*** |
1099+
| **setBoolean()** | ***Used to set the value of a particular element with its index as per, if the data type is Boolean*** |
1100+
| **setByte()** | ***Used to set the value of a particular element with its index as per, if the data type is Byte*** |
1101+
| **setChar()** | ***Used to set the value of a particular element with its index as per, if the data type is Char*** |
1102+
| **setInt()** | ***Used to set the value of a particular element with its index as per, if the data type is Int*** |
1103+
| **setDouble()** | ***Used to set the value of a particular element with its index as per, if the data type is Double*** |
1104+
1105+
Code Link : [Click_me](https://github.com/ackwolver335/Java-Coder/blob/main/arr_reflect.java)
1106+
10271107
## Social Media Links :
10281108

10291109
- [Instagram Page](https://www.instagram.com/coding.needs/)

0 commit comments

Comments
 (0)