Multidimensional arrays are array that contain other arrays. The two-dimensional array is the most basic multidimensional array. Placing each array within its own set of square brackets. We have two arrays in the code, so res= [1][0] means: choose second array list and select the first string with array position of 0.
public class MutiArr { public static void main(String[] args) { /*Creates two-dimensional array & assigning variable name to arrays */ String [ ][ ] names = { {"apple","orange","grapes"}, {"nameOne","nameTwo","nameThree"} }; String res = names[1][0]; #position of string System.out.println(res); String res1 = names[0][0]; System.out.println(res1); } }
nameOne apple
Comments :