About 50 results
Open links in new tab
  1. How do I declare and initialize an array in Java?

    Jul 29, 2009 · You can either use array declaration or array literal (but only when you declare and affect the variable right away, array literals cannot be used for re-assigning an array). For primitive types:

  2. arraylist - How to use an array list in Java? - Stack Overflow

    The use of raw types is allowed only as a concession to compatibility of legacy code. The use of raw types in code written after the introduction of genericity into the Java programming language is …

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

    Jul 15, 2009 · We use the Arrays.stream() method to create a stream of the array elements. We then call the anyMatch() method to check if any of the elements in the stream match the value "orange".

  4. java - Use an array as a case statement in switch - Stack Overflow

    Dec 18, 2013 · Make sure that if you change the length (or order) of the array, it still works, if you want to avoid a rewrite of every 'case' statement. If Java doesn't permit a function call for each 'case', a …

  5. java - Make copy of an array - Stack Overflow

    Java Array Copy Methods Object.clone (): Object class provides clone () method and since array in java is also an Object, you can use this method to achieve full array copy.

  6. java - Create ArrayList from array - Stack Overflow

    Oct 1, 2008 · As of java 8, Collectors.toList() will return an ArrayList. However this may differ in future versions on java.If you want a specific type of collection then use Collectors.toCollection() instead …

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

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

    Is there any fast (and nice looking) way to remove an element from an array in Java?

  9. How do I know whether to use an array or an arraylist?

    Jul 21, 2014 · Though Autoboxing of Java 5 may give you an impression of storing primitives in ArrayList, it actually automatically converts primitives to Object. Java provides add() method to insert …

  10. pass array to method Java - Stack Overflow

    Oct 23, 2009 · Important Points you have to use java.util package array can be passed by reference In the method calling statement Don't use any object to pass an array only the array's name is used, …