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

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

    Calling the static method newInstance in java.lang.reflect.Array returns as an Object an array of the type represented by the Class object passed as the first argument and of the length specified by the int …

  4. java - Create ArrayList from array - Stack Overflow

    Oct 1, 2008 · Note that the returned type for asList() is a List using a concrete ArrayList implementation, but it is NOT java.util.ArrayList. It's an inner type, which emulates an ArrayList but actually directly …

  5. Syntax for creating a two-dimensional array in Java

    If you want to store n elements then the array index starts from zero and ends at n-1. Another way of creating a two dimensional array is by declaring the array first and then allotting memory for it by …

  6. When should I use "new" when creating an array in Java?

    Dec 5, 2023 · When should I use "new" when creating an array in Java? [duplicate] Ask Question Asked 2 years, 2 months ago Modified 2 years, 2 months ago

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

    @Terence: It does the same as the first: It creates an array of string array references, initialized to the values array1, array2, array3, array4 and array5 - each of which is in itself a string array reference.

  8. What does the new operator do when creating an array in java?

    Jul 25, 2015 · And why do we use new while creating an array? Because arrays in Java are objects. The name of the array arrayName in above example is not the actual array, but just a reference. The new …

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

  10. Purpose of new keyword in creating array in Java - Stack Overflow

    Nov 28, 2015 · Also in java the length of the array and other data are saved on the array, for this reason you don't have to declare size of array during declaration, instead when creating an array (using …