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

    Jul 29, 2009 · 3263 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. 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 …

  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. 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 =...

  7. 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 [].

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

  9. How do I determine whether an array contains a particular value in Java ...

    Jul 15, 2009 · If the array is sorted, you can do a binary search, there's one in the Arrays class. Generally speaking, if you are going to do a lot of membership checks, you may want to store …

  10. How do you find the sum of all the numbers in an array in Java?

    Dec 29, 2010 · I'm having a problem finding the sum of all of the integers in an array in Java. I cannot find any useful method in the Math class for this.