About 202,000 results
Open links in new tab
  1. java - How to add new elements to an array? - Stack Overflow

    Mar 12, 2023 · There are many ways to add an element to an array. You can use a temp List to manage the element and then convert it back to Array or you can use the …

  2. How can I concatenate two arrays in Java? - Stack Overflow

    Sep 17, 2008 · Here's my slightly improved version of Joachim Sauer's concatAll. It can work on Java 5 or 6, using Java 6's System.arraycopy if it's available at runtime. This method (IMHO) …

  3. add an element to int [] array in java - Stack Overflow

    Apr 9, 2013 · Want to add or append elements to existing array int[] series = {4,2}; now i want to update the series dynamically with new values i send.. like if i send 3 update series as int[] …

  4. java - How to add an element to Array and shift indexes ... - Stack ...

    I need to add an element to Array specifying position and value. For example, I have Array int []a = {1, 2 ...

  5. java - How to add an element at the end of an array? - Stack …

    Feb 20, 2018 · Adding an element becomes as simple a filling the next index and incrementing the index. If the array fills up completely, a new array is created with more free space. And …

  6. How can I dynamically add items to a Java array?

    Apache Commons has an ArrayUtils implementation to add an element at the end of the new array: /** Copies the given array and adds the given element at the end of the new array. */ …

  7. Simplest way to add an item to beginning of an array in Java

    Feb 2, 2022 · Basically it uses java.util.Arrays.asList() to turn the array into a List, adds to the list and then turns the list back into an array with List.toArray(). As everybody has said, you can't …

  8. java - add string to String array - Stack Overflow

    Dec 31, 2012 · Since Java arrays hold a fixed number of values, you need to create a new array with a length of 5 in this case. A better solution would be to use an ArrayList and simply add …

  9. java - How to add an Array into Set properly? - Stack Overflow

    Dec 27, 2015 · myTest.java:192: error: no suitable constructor found for HashSet(List<int[]>) Note that arrays in java are Objects so Arrays.asList(int[]) will internally consider int[] as a single …

  10. java - Insert array into another array - Stack Overflow

    May 11, 2017 · If you're using a java.util.List, then use List.addAll(int location, Collection a). If you're using arrays, then you'll need to perform the array allocation and copying yourself. …

Refresh