Aug 30, 2024
dataType[] arrayName = new dataType[size];
int[] arr = new int[5];
int[] arr = new int[5];
arr[0] = 10;
arr[1] = 20;
arr[2] = 30;
arr[3] = 40;
arr[4] = 50;
for(int i = 0; i < arr.length; i++) {
System.out.println("Element at index " + i + " is " + arr[i]);
}
int[] arr = new int[5];
int[][] arr = { {1, 2, 3}, {4, 5, 6} };
sum += arr[i];
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
int binarySearch(int[] arr, int left, int right, int x) {
// Implementation
}
void bubbleSort(int[] arr) {
// Implementation
}