Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 正确打印格式_Java - Fatal编程技术网

Java 正确打印格式

Java 正确打印格式,java,Java,要正确打印出这条语句,有点复杂,因为在打印出2d数组中的一列之后,我需要一个“|” System.out.println(toprow); System.out.println(botrow); System.out.println(line2); for(row=0;row<22;row++) { System.out.printf("%02d%s ", row,"|"); for(col=0;col<32;c

要正确打印出这条语句,有点复杂,因为在打印出2d数组中的一列之后,我需要一个“|”

    System.out.println(toprow);
    System.out.println(botrow);
    System.out.println(line2);
    for(row=0;row<22;row++)
      {
      System.out.printf("%02d%s ", row,"|");
        for(col=0;col<32;col++)
          System.out.printf("%s",mapicons[row][col]);
          System.out.printf("%s", "|");
        System.out.println();
      }

不知道如何在末尾排列“|”。如果我将它添加到col for语句中的第一个printf语句中,它将为每列打印一个“|”。因此,我不知道如何消除它在两个打印语句之间自动占用的空格。

打印每行的左侧时,似乎有一个多余的空格字符:

//                       v-- here
System.out.printf("%02d%s ", row,"|");
移除它;其他一切看起来都很好

System.out.printf("%02d%s", row,"|");

打印每行的左侧时,似乎有一个无关的空格字符:

//                       v-- here
System.out.printf("%02d%s ", row,"|");
移除它;其他一切看起来都很好

System.out.printf("%02d%s", row,"|");

打印每行的左侧时,似乎有一个无关的空格字符:

//                       v-- here
System.out.printf("%02d%s ", row,"|");
移除它;其他一切看起来都很好

System.out.printf("%02d%s", row,"|");

打印每行的左侧时,似乎有一个无关的空格字符:

//                       v-- here
System.out.printf("%02d%s ", row,"|");
移除它;其他一切看起来都很好

System.out.printf("%02d%s", row,"|");

首先,总是在块周围使用大括号,并固定缩进。您的代码非常混乱。首先,请始终在块周围使用大括号,并修复缩进。您的代码非常混乱。首先,请始终在块周围使用大括号,并修复缩进。您的代码非常混乱。首先,请始终在块周围使用大括号,并修复缩进。您的代码非常混乱。