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

    Jul 29, 2009 · 3261 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 primitive …

  2. java - Difference between int [] array and int array - Stack Overflow

    Oct 24, 2010 · They are semantically identical. The int array[] syntax was only added to help C programmers get used to Java. 👉 int[] array is much preferable and less confusing.

  3. java - Adding integers to an int array - Stack Overflow

    I am trying to add integers into an int array, but Eclipse says: cannot invoke add(int) on the array type int[] Which is completely illogical to me. I also tried addElement() and addInt(), however

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

  5. How to make an array of integer arrays in Java? - Stack Overflow

    Mar 6, 2019 · I have been trying to make an array of integer arrays. I know that the outer array will have length N whilst every integer array within in only needs to hold two values. Originally, I made an Arra...

  6. How can I convert List<Integer> to int [] in Java? [duplicate]

    How can I convert a List<Integer> to int [] in Java? I'm confused because List.toArray () actually returns an Object [], which can be cast to neither Integer [] nor int [].

  7. How to convert int [] into List<Integer> in Java? - Stack Overflow

    Jul 2, 2009 · How do I convert int[] into List<Integer> in Java? Of course, I'm interested in any other answer than doing it in a loop, item by item. But if there's no other answer, I'll pick that one as the …

  8. java - int [] and Integer [] arrays - What is the difference? - Stack ...

    Sep 17, 2013 · Integer is an object. When you have an array of Integer s, you actually have an array of objects. Array of int s is an array of primitive types. Since arrays are objects, they're allocated on the …

  9. What's the simplest way to print a Java array? - Stack Overflow

    In Java, arrays don't override toString (), so if you try to print one directly, you get the className + '@' + the hex of the hashCode of the array, as defined by Object.toString (): int [] intArray =...

  10. How do I reverse an int array in Java? - Stack Overflow

    Jan 26, 2010 · java.util.Collections.reverse() can reverse java.util.List s and java.util.Arrays.asList() returns a list that wraps the the specific array you pass to it, therefore yourArray is reversed after the …