1. public static void main(String[] args) {
    2. char[][] chs = new char[3][];
    3. chs[0] = new char[]{'1','2','3'};
    4. chs[1] = new char[]{'4','5','6'};
    5. chs[2] = new char[]{'7','8','9'};
    6. //遍历二维数组
    7. for (int i = 0; i < chs.length; i++) {
    8. char [] items = chs[i];
    9. for (int j = 0; j < items.length; j++) {
    10. System.out.print(items[j] + "\t");
    11. }
    12. System.out.println();
    13. // 1 2 3
    14. // 4 5 6
    15. // 7 8 9
    16. }
    17. System.out.println("---------");
    18. for (int i = 0; i < chs.length; i++) {
    19. char [] items = chs[i];
    20. for (int j = 0; j < items.length; j++) {
    21. System.out.print(chs[i][j] + "\t");
    22. }
    23. System.out.println();
    24. }
    25. // 1 2 3
    26. // 4 5 6
    27. // 7 8 9
    28. }