Java tutorial
//package com.java2s; import java.util.Arrays; public class Main { /** * creates a table showing target value (arbitrary) and bitArray it should * be assigned to *. * * @param array * the array * @return the double[][][] */ public static double[][][] createConversionTable(double[] array) { return createConversionTable(array, false); } /** * creates a table showing target value (arbitrary) and bitArray it should * be assigned to *. * * @param array * the array * @param verbose * the verbose * @return the double[][][] */ public static double[][][] createConversionTable(double[] array, boolean verbose) { int length = array.length; double[][][] bArray = new double[length][2][length]; int i = 0; for (double val : array) { // don't actually need value bArray[i][0] = new double[] { val }; // original value for (int j = 0; j < length; ++j) { // Think it is a bit confusing if // I for each this... bArray[i][1][j] = 0; // every value 0 except... } bArray[i][1][length - i - 1] = 1; // this guy i++; } if (verbose) { System.out.println("Conversion table:\n" + Arrays.deepToString(bArray)); } return bArray; } /** * creates a table showing target value (arbitrary) and bitArray it should * be assigned to *. * * @param array * the array * @param verbose * the verbose * @return the string[][][] */ public static String[][][] createConversionTable(String[] array, boolean verbose) { int length = array.length; String[][][] bArray = new String[length][2][length]; int i = 0; for (String val : array) { // don't actually need value bArray[i][0] = new String[] { array[i] }; // original value for (int j = 0; j < length; ++j) { // Think it is a bit confusing if // I for each this... bArray[i][1][j] = "0"; // every value 0 except... } bArray[i][1][length - i - 1] = "1"; // this guy i++; } if (verbose) { System.out.println("Conversion table:\n" + Arrays.deepToString(bArray)); } return bArray; } }