In: Computer Science
java
declare at least five different types of arrays, one, two and three-dimension.
if you have any question or queries just comment below. Thank you.
1. int:
1D: int[] arr = new int[n]; where n is number elements in array.
2D: int[][] arr = new int[n][m]; where n is number rows and m is number of columns.
3D: int[][][] arr = new int[n][m][l]; where n is array number, m is number of rows, l is number of columns.
2. String:
1D: String[] arr = new String[n]; where n is number elements in array.
2D: String[][] arr = new String[n][m]; where n is number rows and m is number of columns.
3D: String[][][] arr = new String[n][m][l]; where n is array number, m is number of rows, l is number of columns.
3. float:
1D: float[] arr = new float[n]; where n is number elements in array.
2D: float[][] arr = new float[n][m]; where n is number rows and m is number of columns.
3D: float[][][] arr = new float[n][m][l]; where n is array number, m is number of rows, l is number of columns.
4. double:
1D: double[] arr = new double[n]; where n is number elements in array.
2D: double[][] arr = new double[n][m]; where n is number rows and m is number of columns.
3D: double[][][] arr = new double[n][m][l]; where n is array number, m is number of rows, l is number of columns.
5. char:
1D: char[] arr = new char[n]; where n is number elements in array.
2D: char[][] arr = new char[n][m]; where n is number rows and m is number of columns.
3D: char[][][] arr = new char[n][m][l]; where n is array number, m is number of rows, l is number of columns.