About 77,500 results
Open links in new tab
  1. Initialising a multidimensional array in Java - Stack Overflow

    Dec 4, 2013 · Multidimensional Array in Java Returning a multidimensional array. Java does not truely support multidimensional arrays. In Java, a two-dimensional array is simply an array of …

  2. Syntax for creating a two-dimensional array in Java

    Jan 17, 2021 · In Java, a two-dimensional array can be declared as the same as a one-dimensional array. In a one-dimensional array you can write like. int array[] = new int[5]; where …

  3. java - Initialize 2D array - Stack Overflow

    Dec 12, 2012 · I am trying to initialize a 2D array, in which the type of each element is char. So far, I can only initialize this array in the follow way. public class ticTacToe { private char[][] …

  4. How to initialize 2D ArrayList in Java? - Stack Overflow

    @user2458768 Take a look at the code that prints the array (look at the updated demo to see it run on ideone). – Sergey Kalinichenko Commented Nov 9, 2013 at 18:37

  5. Arrays.fill with multidimensional array in Java - Stack Overflow

    Nov 24, 2019 · This is because a double[][] is an array of double[] which you can't assign 0.0 to (it would be like doing double[] vector = 0.0). In fact, Java has no true multidimensional arrays. …

  6. How to initialize two dimensional array in java 8

    Aug 28, 2018 · The composition of the outer array is a bit tricky since int[] is no longer a primitive value but an array itself. There is needed to use a method IntStream::mapToObj which maps …

  7. java - How do I initialize a two-dimensional array? - Stack Overflow

    Jul 9, 2015 · The array is initialised, but if you want individual elements of the array to be initialised, you have to do that as well, either in the initial line like this: point[] p1 = new point[] { …

  8. How do I declare and initialize an array in Java?

    Jul 29, 2009 · You can either use array declaration or array literal (but only when you declare and affect the variable right away, array literals cannot be used for re-assigning an array). For …

  9. Initialization of 2D Array in Java? - Stack Overflow

    Aug 1, 2021 · As an aside, although putting array brackets on the variable name is possible in Java, the recommended way is to put them on the type, so int[][] arr instead of int arr[][]. – …

  10. 2D array static initialisation in java - Stack Overflow

    Aug 20, 2014 · Here's an example of how to initialize the array in a static initializer block. Of course, it's not very interesting, since all the integers in the array are identical. class Abc { …