Refine search
String[][] deepArray = new String[][] {{"John", "Mary"}, {"Alice", "Bob"}}; System.out.println(Arrays.toString(deepArray)); //output: [[Ljava.lang.String;@106d69c, [Ljava.lang.String;@52e922] System.out.println(Arrays.deepToString(deepArray));
String[][] x = new String[][] { new String[] { "foo", "bar" }, new String[] { "bazz" } }; Log.d("this is my deep array", "deep arr: " + Arrays.deepToString(x)); // or System.out.println("deep arr: " + Arrays.deepToString(x)); // will output: [[foo, bar], [bazz]]
int[][] array = new int[rows][columns]; System.out.println(Arrays.deepToString(array));
String[][] aastr = {{"hello", "world"},{"Goodbye", "planet"}}; System.out.println(Arrays.deepToString(aastr));
public static void main(String[] args) { int twoD[][] = new int[4][]; twoD[0] = new int[1]; twoD[1] = new int[2]; twoD[2] = new int[3]; twoD[3] = new int[4]; System.out.println(Arrays.deepToString(twoD)); }
int[] nums = { 1, 2, 3 }; System.out.println(nums); // [I@xxxxx System.out.println(Arrays.toString(nums)); // [1, 2, 3] int[][] table = { { 1, }, { 2, 3, }, { 4, 5, 6, }, }; System.out.println(Arrays.toString(table)); // [[I@xxxxx, [I@yyyyy, [I@zzzzz] System.out.println(Arrays.deepToString(table)); // [[1], [2, 3], [4, 5, 6]]
System.out.println( java.util.Arrays.toString( new int[][] { { 1 }, { 2, 3 }, } ) ); // prints "[[I@187aeca, [I@e48e1b]" System.out.println( java.util.Arrays.deepToString( new int[][] { { 1 }, { 2, 3 }, } ) ); // prints "[[1], [2, 3]]"
import java.util.*; public class Test { public static void main(String args[]) { int[][] twoDim = { {1, 2}, {3, 7}, {8, 9}, {4, 2}, {5, 3} }; Arrays.sort(twoDim, Comparator.comparing((int[] arr) -> arr[0]) .reversed()); System.out.println(Arrays.deepToString(twoDim)); } }
String data = "1|apple,2|ball,3|cat"; String[] rows = data.split(","); String[][] matrix = new String[rows.length][]; int r = 0; for (String row : rows) { matrix[r++] = row.split("\\|"); } System.out.println(matrix[1][1]); // prints "ball" System.out.println(Arrays.deepToString(matrix)); // prints "[[1, apple], [2, ball], [3, cat]]"
Scanner sc = new Scanner(data).useDelimiter("[,|]"); final int M = 3; final int N = 2; String[][] matrix = new String[M][N]; for (int r = 0; r < M; r++) { for (int c = 0; c < N; c++) { matrix[r][c] = sc.next(); } } System.out.println(Arrays.deepToString(matrix)); // prints "[[1, apple], [2, ball], [3, cat]]"
List<List<String>> ls2d = new ArrayList<List<String>>(); List<String> x = new ArrayList<String>(); x.add("Hello"); x.add("world!"); ls2d.add(x); System.out.println(Arrays.deepToString(ls2d.toArray()));
@Override public int run(String[] args) throws Exception { if (args.length < 5) { System.err.println(USAGE); return 1; LOG.info("Running Loop with args:" + Arrays.deepToString(args)); for (int i = 0; i < numIterations; i++) { LOG.info("Starting iteration = " + i); System.err.println("Parsing loop arguments failed: " + e.getMessage()); System.err.println(USAGE); return 1;
if (args.length < 5) { System.err .println("Usage: Loop <num iterations> " + "<num mappers> <num nodes per mapper> <output dir> " + "<num reducers> [<width> <wrap multiplier>]"); return 1; LOG.info("Running Loop with args:" + Arrays.deepToString(args));
BigInteger[][] bigIntegerMatrix = zeroMatrix(BigInteger.class, 3, 3); Integer[][] integerMatrix = zeroMatrix(Integer.class, 3, 3); Float[][] floatMatrix = zeroMatrix(Float.class, 3, 3); String[][] error = zeroMatrix(String.class, 3, 3); // <--- compile time error System.out.println(Arrays.deepToString(bigIntegerMatrix)); System.out.println(Arrays.deepToString(integerMatrix)); System.out.println(Arrays.deepToString(floatMatrix));
for (Model m : ms) { KMeansModel kmm = (KMeansModel) m; System.out.println(kmm._output._tot_withinss + " " + Arrays.deepToString( ArrayUtils.zip(grid.getHyperNames(), grid.getHyperValues(kmm._parms)))); GridTestUtils.extractParams(usedModelParams, kmm._parms, hyperParamNames);
System.out.println(Arrays.deepToString(table).replaceAll("],", "]," + System.getProperty("line.separator")));
List<int[]> listOfIntArrays = new ArrayList<int[]>(); listOfIntArrays.add(new int[] { 10, 20, 30 }); listOfIntArrays.add(new int[] { 11, 21, 31 }); listOfIntArrays.add(new int[] { 12, 22, 32 }); int[][] intMatrix = listOfIntArrays.toArray(new int[0][]); System.out.println(Arrays.deepToString(intMatrix));
public static void main(String[] args) { int[][] int2DArray = new int[][] { {11, 12}, { 21, 22}, {31, 32, 33} }; String[][] str2DArray = new String[][]{ {"John", "Bravo"} , {"Mary", "Lee"}, {"Bob", "Johnson"} }; //Prior to Java 8 System.out.println(Arrays.deepToString(int2DArray)); System.out.println(Arrays.deepToString(str2DArray)); // In Java 8 we have lambda expressions Arrays.stream(int2DArray).flatMapToInt(x -> Arrays.stream(x)).forEach(System.out::println); Arrays.stream(str2DArray).flatMap(x -> Arrays.stream(x)).forEach(System.out::println); }
for (Model m : ms) { DRFModel drf = (DRFModel) m; System.out.println( drf._output._scored_train[drf._output._ntrees]._mse + " " + Arrays.deepToString( ArrayUtils.zip(grid.getHyperNames(), grid.getHyperValues(drf._parms)))); GridTestUtils.extractParams(usedModelParams, drf._parms, hyperParamNames);
for (Key<Model> mKey : mKeys) { GBMModel gbm = (GBMModel) mKey.get(); System.out.println(gbm._output._scored_train[gbm._output._ntrees]._mse + " " + Arrays.deepToString( ArrayUtils .zip(grid.getHyperNames(), grid.getHyperValues(gbm._parms))));