我無法弄清楚如何從arraylist格式化我的打印, 我只是不知道該怎麼做。任何提示或片段可以幫助嗎?謝謝搞清楚如何格式化打印
protected void printTable(ArrayList<double[]> table)
{
String s = "";
System.out.printf("\n_____________________________________________________\n");
System.out.printf("\n x\t f[]\t f[,] f[,,] f[,,,] ");
System.out.printf("\n_____________________________________________________\n");
for(int a = 0; a < table.size(); a++)
{
System.out.printf("%.3s", s);
for(double c : table.get(a))
{
System.out.printf("%.3f\t " , c);
}
System.out.println();
}
}
它這樣印刷的時刻:
_____________________________________________________
x f[] f[,] f[,,] f[,,,]
_____________________________________________________
1.000 1.500 0.000 2.000
3.000 3.250 3.000 1.670
0.500 0.167 -0.665
0.333 -1.663
-1.997
我怎麼得到它呢?
_____________________________________________________
x f[] f[,] f[,,] f[,,,]
_____________________________________________________
1.000 3.000 0.500 0.333 -1.997
1.500 3.250 0.167 -1.663
0.000 3.000 -0.665
2.000 1.670
謝謝,但我該如何旋轉它? – 2014-11-25 08:42:31
除了數組的ArrayList,您可以使用2維數組double [] []。然後你可以更明確地控制你的迭代器 – CocoNess 2014-11-25 09:22:29