简体   繁体   English

打印二维数组并为奇数打印 *

[英]print 2D array and print * for odd numbers

enter image description here why does the console print my 2D array in a row? enter image description here为什么控制台连续打印我的二维数组?

You're using System.out.print which doesn't append a newline to the end of your output, meaning it will just keep printing everything to the same line.您正在使用System.out.print ,它不会 append 在您的 output 末尾换行,这意味着它只会将所有内容打印到同一行。

You can add the line System.out.println() inside your top-level loop, but after your inner loop, and it will log each 2nd-level array to it's own line.您可以在顶层循环中添加System.out.println()行,但在内部循环之后,它会将每个二级数组记录到它自己的行中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM