簡體   English   中英

如何讓數組表每隔一行打印一次?

[英]How to get an array table to print every other line?

我曾嘗試處理不同的事情並查找,但我可能使用了不正確的措辭。 我只是想知道空行在數組索引中的位置。 感謝您的任何幫助/指導。

I'm wanting my output to look like:
Course        Hours    Score   Grade
CS121           4       98      A
// mine doesn't have this blank line
Math161         3       55      F
// or this blank line
CS124           3       66      D

我的最后一個打印語句: System.out.printf("%-10s %d %5d %5c\\n", courses[i], credits[i], scores[i], letterGrades[i]);

\\n (不可移植的換行符和單數)更改為%n%n 喜歡,

System.out.printf("%-10s %d %5d %5c%n%n", courses[i], credits[i], scores[i], 
        letterGrades[i]);

或者添加一個空的System.out.println(); 緊隨其后(添加新行)。

System.out.printf("%-10s %d %5d %5c%n", courses[i], credits[i], scores[i], 
        letterGrades[i]);
System.out.println();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM