标签:包装 sys name demo dem new 1.0 class split
将String s = "1,2;3,4,5;6,7,8" 存放在double类型的二维数组中,使得
d[0][0]=1.0
d[0][1]=2.0d[2][2]=8.0
public class IntegerDemo { public static void main(String[] args) { String s = "1,2;3,4,5;6,7,8"; double[][] d; String[] split = s.split(";"); d = new double[split.length][]; for (int i = 0; i < split.length; i++) { String[] split2 = split[i].split(","); d[i] = new double[split2.length]; for (int j = 0; j < split2.length; j++) { d[i][j] = Double.parseDouble((split2[j])); } } for (int i = 0; i < d.length; i++) { for (int j = 0; j < d[i].length; j++) { System.out.println("d["+i+"]["+j+"]="+d[i][j]); } } } }
标签:包装 sys name demo dem new 1.0 class split
原文地址:http://www.cnblogs.com/wzjhoutai/p/6920124.html