📄 arrayofarrays.java
字号:
package chapter5;
public class ArrayofArrays {
public static void main(String[] args) {
String[][] cartoons = {
{ "Flintstones", "Fred", "Willma", "Pebbles", "Dino" },
{ "Rubbles", "Barney", "Betty", "Bam Bam" },
{ "Scooby Doo Gang", " Scooby Doo", " Shaggy", "Velma", "Fred",
"Daphne" } }; // 定义二维数组变量,第二维长度不一致
for (int i = 0; i < cartoons.length; i++) {
System.out.print(cartoons[i][0] + ":"); // 输出cartoons数组第一列元素
for (int j = 1; j < cartoons[i].length; j++) {
System.out.print(cartoons[i][j] + " "); // 输出cartoons数组
}
System.out.println();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -