About 19,300,000 results
Open links in new tab
  1. Convert list to array in Java - Stack Overflow

    There are two styles to convert a collection to an array: either using a pre-sized array (like c.toArray (new String [c.size ()])) or using an empty array (like c.toArray (new String [0]). In …

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

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

    An array initializer creates an array and provides initial values for all its components. and this is irrespective of whether the array is an instance variable or local variable or class variable.

  4. How to make an array of arrays in Java - Stack Overflow

    While there are two excellent answers telling you how to do it, I feel that another answer is missing: In most cases you shouldn't do it at all. Arrays are cumbersome, in most cases you …

  5. How do I declare and initialize an array in Java? - Stack Overflow

    Jul 29, 2009 · This answer fails to properly address the question: "How do I declare and initialize an array in Java?" Other answers here show that it is simple to initialize float and int arrays …

  6. Get only part of an Array in Java? - Stack Overflow

    The length of an array in Java is immutable. So, you need to copy the desired part into a new array. Use copyOfRange method from java.util.Arrays class:

  7. Java, Shifting Elements in an Array - Stack Overflow

    I have an array of objects in Java, and I am trying to pull one element to the top and shift the rest down by one. Assume I have an array of size 10, and I am trying to pull the fifth element. The...

  8. java - How to get unique values from array - Stack Overflow

    Why did you first add items into array and then convert it to string? Just iterate over tha array and copy them to Set.Then print new created set which holds unique values.

  9. Removing an element from an Array (Java) - Stack Overflow

    42 You can't remove an element from the basic Java array. Take a look at various Collections and ArrayList instead.

  10. Resize an Array while keeping current elements in Java?

    82 I have searched for a way to resize an array in Java, but I could not find ways of resizing the array while keeping the current elements. I found for example code like int[] newImage = new …