import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; public class MyTestMap { static int barGroupNum;//柱子数分为奇数和偶数 static int total ;//共有的组数 static List<double[]>list; static int align = 2;//每组柱子间隔 static int[]xPoing; public static void main(String[] args) { list = new ArrayList<double[]>(); barGroupNum = 3; total = 4; xPoing = new int[total]; totalData(); int length = list.size(); for (int i = 0; i < length; i++) { double[] d = list.get(i); System.out.println(Arrays.toString(d)); } System.out.println("==============="); System.out.println(Arrays.toString(xPoing)); } private static void totalData() { int count = 0; if(barGroupNum%2 != 0){ for(int i = 1; i <= total; i++){ double[] d = new double[barGroupNum]; for(int j = 1; j <= barGroupNum; j++ ){ int x = (total+1)*(j-1)+i; d[j-1] = x; if(j == (barGroupNum/2+1)){ xPoing[count++] = x; } } list.add(d); } }else{ for(int i = 1; i <= total; i++){ double[] d = new double[barGroupNum]; int j = 1; for(; j <= barGroupNum/2; j++ ){ d[j-1] = (barGroupNum+2)*(i-1)+j; } xPoing[count++] = (barGroupNum+2)*(i-1)+j; int a = j-1; for(j = barGroupNum/2+2; j <= barGroupNum+1; j++ ){ d[a++] = (barGroupNum+2)*(i-1)+j; } list.add(d); } } } }