bookShop.length與bookShop[i]的差別,在陣列中
class Array_2D_Irregular{
public static void main(String[] args){
String[] shopName = {"梵谷書店", "麗莎書店"};
String[][] bookShop = {{"亂世佳人","雙城記","科學怪人","小美人魚"},
{"亂世佳人","睡美人","天方夜譚"}};
for(int i=0; i<bookShop.length; i++){
System.out.print(shopName[i] + " ");
for(int j=0; j<bookShop[i].length; j++)
System.out.print(bookShop[i][j] + " ");
System.out.println();
}
}
}
public static void main(String[] args){
String[] shopName = {"梵谷書店", "麗莎書店"};
String[][] bookShop = {{"亂世佳人","雙城記","科學怪人","小美人魚"},
{"亂世佳人","睡美人","天方夜譚"}};
for(int i=0; i<bookShop.length; i++){
System.out.print(shopName[i] + " ");
for(int j=0; j<bookShop[i].length; j++)
System.out.print(bookShop[i][j] + " ");
System.out.println();
}
}
}
留言
張貼留言