double[][]转为String字符串
有如下的double[][]
double[][] doubleArray={{1,2,3,4,5},{11,22,33,44,55},[111,222,333,444,555].....}
现在想把以上的double[][]转为以下格式的字符串 1,11,111;2,22,222;3,33,333;4,44,444;5,55,555;
请高手帮帮忙。。谢谢了
------解决方案--------------------public static void main(String[] args) {
double[][] doubleArray={{1,2,3,4,5},{11,22,33,44,55},{111,222,333,444,555}};
StringBuffer sb = new StringBuffer();
for(int i=0; i <doubleArray[0].length; i++){
for(int j=0; j <doubleArray.length; j++){
sb.append(String.format( "%.0f ", doubleArray[j][i]));
if(j <doubleArray.length-1) {
sb.append( ", ");
}
}
sb.append( "; ");
}
System.out.println(sb.toString());
}