提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建二维数组
public class ArrayOfArraysDemo {/** 来自 时 代 Java - nowjava.com**/ public static void main(String[] args) { String[][] cartoons = { { "Flintstones", "Fred", "Wilma", "Pebbles", "Dino" }, { "Rubbles", "Barney", "Betty", "Bam Bam" }, { "Jetsons", "George", "Jane", "Elroy", "Judy", "Rosie", "Astro" }, { "Scooby Doo Gang", "Scooby Doo", "Shaggy", "Velma", "Fred", "Daphne" } }; for (int i = 0; i < cartoons.length; i++) { System.out.print(cartoons[i][0] + ": "); for (int j = 1; j < cartoons[i].length; j++) { System.out.print(cartoons[i][j] + " ");/*from 时代Java - N o w J a v a . c o m*/ } System.out.println(); } } }