About 16,300,000 results
Open links in new tab
  1. 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 when they …

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

    Jul 15, 2009 · How do I determine whether an array contains a particular value in Java? Asked 16 years, 4 months ago Modified 3 months ago Viewed 2.8m times

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

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

    FYI, Arrays.deepToString() accepts only an Object [] (or an array of classes that extend Object, such as Integer, so it won't work on a primitive array of type int []. But Arrays.toString(<int array>) works fine …

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

  8. Sort an array in Java - Stack Overflow

    Jan 20, 2012 · Be aware that Arrays.sort () method is not thread safe: if your array is a property of a singleton, and used in a multi-threaded enviroment, you should put the sorting code in a …

  9. java - How to add new elements to an array? - Stack Overflow

    May 16, 2010 · The size of an array can't be modified. If you want a bigger array you have to instantiate a new one. A better solution would be to use an ArrayList which can grow as you need it. The …

  10. How to create correct JSONArray in Java using JSONObject

    In java 6 org.json.JSONArray contains the put method and in java 7 javax.json contains the add method. An example of this using the builder pattern in java 7 looks something like this: