如何解决打印2D数组-Eclipse和PowerShell Java的不同结果
基本上,我有一个简单的应用程序,您可以插入2D数组的尺寸(x,y),它将在控制台上打印其边框。 例如,如果您插入2 2,它将打印:
----
| |
| |
----
这将在Eclipse控制台和Windows PowerShell中正确打印,但是如果我在Cygwin ou git bash上运行应用程序(使用java -jar myApp.java),则应用程序会打印:
2 2
----
||
||
----
我的打印方式是:
String LINE_SEPERATOR = System.getProperty("line.separator");
public void render() {
StringBuilder drawnCanvas = new StringBuilder();
for (int row = 0; row < this.canvas.length; ++row) {
for (int col = 0; col < this.canvas[row].length; col++) {
drawnCanvas.append(this.canvas[row][col]);
}
drawnCanvas.append(LINE_SEPERATOR);
}
System.out.println(drawnCanvas.toString());
}
print of the actual consoles differences
有人知道这个问题可能是什么吗? 谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。