此代码打印每行的总和....如何转换它以便打印每列的总和?谢谢,,
public class NewClass{
public static void main( String[] arg )
{
int[][] data =
{ { 1, 2},
{ 2, 2},
{ 1, 2, 4, 5},
{ 2, 2, 4,},
{ 1, 1, 4, 5 },
{ 2, 1, }};
for ( int row=0; row < data.length; row++)
{
int sum = 0;
for ( int col=0; col < data[row].length; col++)
{
sum = sum + data[row][col];
}
System.out.print("Sum of Row " + row+" is : ");
System.out.println( sum );
}
}
}