About 176,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. 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:

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

    This then means that you can create an array object of the appropriate type in your constructor, which means that the type of the objects you store in your collection will have their types …

  4. 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 - A[] arr = new A[4]; But this is only creating pointers (references) to A and not 4 …

  5. java - How to create an empty array? - Stack Overflow

    Read user input into a variable and use its value to initialize the array. myArray = new int[someVarSetEarlier] if you want to get the size in advance or use a List if you want the …

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

  7. java - How to quickly and conveniently create a one element …

    The reason this method in Arrays class is because, the method is really converting from array to a list. The method is defined to take var-args. So, whatever arguments you pass to it is internally …

  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. java - Creating new array with contents from old array while …

    You could create the new array in the size you want (4 in this case), and then use System.arrayCopy to copy the contents from one array to another.

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