About 155,000 results
Open links in new tab
  1. How do I declare and initialize an array in Java?

    Jul 29, 2009 · Declare Array: int[] arr; Initialize Array: int[] arr = new int[10]; 10 represents the number of elements allowed in the array. Declare Multidimensional Array: int[][] arr; Initialize …

  2. Java Initialize an int array in a constructor - Stack Overflow

    in your constructor you are creating another int array: public Date(){ int[] data = {0,0,0}; } Try this: data = {0,0,0}; NOTE: By the way you do NOT need to initialize your array elements if it is …

  3. How to initialize an array in Java? - Stack Overflow

    Dec 21, 2009 · If you want to initialize an array in a constructor, you can't use those array initializer like. data= {10,20,30,40,50,60,71,80,90,91};

  4. How to initialize all the elements of an array to any specific value …

    Whenever we write int[] array = new int[10], this simply initializes an array of size 10 having all elements set to 0, but I just want to initialize all elements to something other than 0 (say, -1). …

  5. java - int array initialization - Stack Overflow

    Nov 22, 2012 · Now, what happens is, when you declare your array reference like this as local variable, and initialize it with an array: - int[] in = new int[5]; The array reference (in) is stored …

  6. What is the default initialization of an array in Java?

    Java says that the default length of a JAVA array at the time of initialization will be 10. private static final int DEFAULT_CAPACITY = 10; But the size() method returns the number of …

  7. java - How to create an empty array? - Stack Overflow

    Apr 15, 2014 · I don't want to define the capacity of the area like int[] myArray = new int[5]; I want to define an empty array for which a user defines the capacity, example- they enter number …

  8. Java: How initialize an array in Java in one line?

    Jul 1, 2010 · FWIW if you send the array to something else (like a graphical list handler) and re-initialize the array like above, the link to the graphical list handler will break. I ran into this while …

  9. 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 …

  10. Variable-sized Array Initialization in Java - Stack Overflow

    Mar 9, 2017 · Since this is an array of int the array elements will get the default value for int's in Java of 0 automatically. If this were an array of Integer objects then you would have to fill array …

Refresh