About 50 results
Open links in new tab
  1. 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 …

  2. java - How to add an element at the end of an array? - Stack Overflow

    Feb 20, 2018 · As many others pointed out if you are trying to add a new element at the end of list then something like, array [array.length-1]=x; should do. But this will replace the existing element.

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

    Sep 17, 2008 · The array created by Arrays.copyOf will have the component type of the first array, i.e. Integer in this example. When the function is about to copy the second array, an …

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

    You can't shift indexes for arrays in Java. Arrays are fixed size. Create new array with values you want and assign the reference 'a' to new array.

  5. java - Adding integers to an int array - Stack Overflow

    7 An array doesn't have an add method. You assign a value to an element of the array with num[i]=value;.

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

    Apr 9, 2013 · The length of an array is immutable in java. This means you can't change the size of an array once you have created it. If you initialised it with 2 elements, its length is 2. You can however …

  7. Add element into array java - Stack Overflow

    Mar 22, 2012 · During this process you will need to decide what to do with the last entry of the array (num[num.length - 1]): You could just overwrite it, discarding the value You could return it from your …

  8. How to add an object to an ArrayList in Java - Stack Overflow

    Oct 27, 2013 · 24 I want to add an object to an ArrayList, but each time I add a new object to an ArrayList with 3 attributes: objt(name, address, contact), I get an error.

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

    The PHP arrays are in fact quite the same as a Java HashMap with an added "max key", so it would know which key to use next, and a strange iteration order (and a strange equivalence relation …

  10. java - Add multiple items to an array - Stack Overflow

    Jul 3, 2014 · String str="Country1,Country2,Country3"; String array[]=str.split(",");//You even don't need to initialize array Use delimeter carefully to avoid extra spaces. NOTE: As this is one of the ways to …