Hi, I'm trying to figure out how to print a string array in such a way that the output will have 2 rows and 2 columns. Here's the portion of my code: Code: String[][] courseArray = {{"art", "science"}, {"history", "mathematics"}}; System.out.println ("\n" + "Courses taken this semester: " + courseArray); I don't know how to construct the for-loop. Help will be greatly appreciated. Thank you!
to print two dimension array, we must use loop in loop. Code: for(condition){ for(condition){ // print array } } Here is the loop example : Code: String[][] courseArray = new String({"Art","Science"},{"History","Mathematics"}); for(int i=0; i<courseArray.length; i++){ for(int j=0; j<courseArray.length; j++){ System.out.println(courseArray[i][j]); } } I think it works