About 1,740,000 results
Open links in new tab
  1. How do I declare and initialize an array in Java? - Stack Overflow

    Jul 29, 2009 · There are various ways in which you can declare an array in Java: float floatArray[]; // Initialize later int[] integerArray = new int[10]; String[] array = new String[] {"a", "b"}; You can …

  2. Creating an array of objects in Java - Stack Overflow

    There are 3 steps to create arrays in Java - Declaration – In this step, we specify the data type and the dimensions of the array that we are going to create. But remember, we don't mention …

  3. java - Creating new array with contents from old array while …

    int[] newArr = new int[4]; System.arraycopy(array, 0, newArr, 0, 4); The method takes five arguments: src: The source array. srcPosition: The position in the source from where you wish …

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

    I do not understand why I need a reflect here.Java grammar is strange: like new java.util.HashMap<String,String>[10] is not valid. new java.util.HashMap<long,long>(10) is not …

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

    Apr 15, 2014 · I don't want to define the capacity of the area like int[] myArray = new int[5]; I want to define an empty array for which a user defines the capacity, example- they enter number …

  6. How do I initialize a byte array in Java? - Stack Overflow

    Jun 26, 2012 · In Java 6, there is a method doing exactly what you want: private static final byte[] CDRIVES = javax.xml.bind.DatatypeConverter.parseHexBinary ...

  7. java - How to initialize HashSet values by construction ... - Stack ...

    Jan 11, 2010 · Keep in mind that this will actually create an new subclass of HashSet each time it is used, even though one does not have to explicitly write a new subclass. A utility method …

  8. initializing a boolean array in java - Stack Overflow

    Mar 2, 2010 · Arrays in Java start indexing at 0. So in your example you are referring to an element that is outside the array by one. It should probably be something like …

  9. How to make a new List in Java - Stack Overflow

    May 13, 2009 · In Java 8. To create a non-empty list of fixed size (operations like add, remove, etc., are not supported): List<Integer> list = Arrays.asList(1, 2); // but, list.set(...) is supported …

  10. Double array initialization in Java - Stack Overflow

    It is called an array initializer and can be explained in the Java specification 10.6. This can be used to initialize any array, but it can only be used for initialization (not assignment to an …

Refresh