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

    Jul 29, 2009 · The third way of initializing is useful when you declare an array first and then initialize it, pass an array as a function argument, or return an array. The explicit type is required.

  2. Creating an array of objects in Java - Stack Overflow

    I am new to Java and for the time created an array of objects in Java. I have a class A for example -

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

    Dec 21, 2009 · Notice the difference between the two declarations. When assigning a new array to a declared variable, new must be used. Even if you correct the syntax, accessing data[10] is still …

  4. java - Any way to declare an array in-line? - Stack Overflow

    Feb 28, 2016 · 38 You can directly write the array in modern Java, without an initializer. Your example is now valid. It is generally best to name the parameter anyway.

  5. java - How can I create an Array of ArrayLists? - Stack Overflow

    I am wanting to create an array of arraylist like below: ArrayList<Individual> [] group = new ArrayList<Individual> () [4]; But it's not compiling. How can I do this?

  6. How can I create a generic array in Java? - Stack Overflow

    That compiles without warnings, and as you can see in main, for whatever type you declare an instance of GenSet as, you can assign a to an array of that type, and you can assign an element …

  7. Array declaration and initialization in Java - Stack Overflow

    Jun 1, 2021 · As a direct answer to your question, this is the case because the Java language was defined in this way. When we declare a new field or local variable, we may initialize it by either …

  8. How do I initialize a byte array in Java? - Stack Overflow

    Jun 26, 2012 · I have to store some constant values (UUIDs) in byte array form in java, and I'm wondering what the best way to initialize those static arrays would be. This is how I'm currently …

  9. Initialising a multidimensional array in Java - Stack Overflow

    Jul 1, 2009 · String[][] myStringArray = new String [x][y]; is the correct way to initialise a rectangular multidimensional array. If you want it to be jagged (each sub-array potentially has a different …

  10. I want to declare an empty array in Java and then I want do update …

    If you don't know the size of the array ahead of time (for example, if you're reading a file and storing the contents), you should use an instead, because that's an array that grows in size …