-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray2d.java
More file actions
23 lines (22 loc) · 812 Bytes
/
array2d.java
File metadata and controls
23 lines (22 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class array2d {
public static void main(String[]args){
//2darray = an array where each element is an array
// useful for sorting a matrix of data
String[] fruits={"apple","banana","orange"};
String[] vege={"potato","onion","carrot"};
String[] meat={"chicken","beef","pork","fish"};
String[][] groceries={fruits,vege,meat};
// String[][] groceries={{"apple","banana","orange"}, can use this way also
// {"potato","onion","carrot"},
// {"chicken","beef","pork","fish"}};
//
for(String[] grow:groceries)
{
for(String food:grow)
{
System.out.print(food+" ");
}
System.out.println();
}
}
}