About 386,000 results
Open links in new tab
  1. java - add string to String array - Stack Overflow

    Dec 31, 2012 · I am new in Java so I need little help. I have . String [] scripts = new String [] ("test3","test4","test5"); and I want to add new strings ( string1,string2) to this array ( scripts) …

  2. java - How to add new elements to an array? - Stack Overflow

    Mar 12, 2023 · Use a List<String>, such as an ArrayList<String>.It's dynamically growable, unlike arrays (see: Effective Java 2nd Edition, Item 25: Prefer lists to arrays).

  3. java - How can I add new item to the String array? - Stack Overflow

    Jan 25, 2013 · So in the case of a String array, once you create it with some length, you can't modify it, but you can add elements until you fill it. String[] arr = new String[10]; // 10 is the …

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

    Sep 17, 2008 · Here's a simple method that will concatenate two arrays and return the result: public <T> T[] concatenate(T[] a, T[] b) { int aLen = a.length; int bLen = b.length ...

  5. java - How to add elements of a string array to a string array list ...

    Oct 12, 2012 · I am trying to pass a string array as an argument to the constructor of Wetland class; I don't understand how to add the elements of string array to the string array list. import …

  6. java - How to dynamically add elements to String array ... - Stack …

    Feb 23, 2013 · Of course, if you know beforehand how many strings you are going to put in your array, you can create an array of that size and set the elements by using the correct position: …

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

    Feb 20, 2018 · public static int[] append(int[] array, int value) { int[] result = Arrays.copyOf(array, array.length + 1); result[result.length - 1] = value; return result; } This quickly gets inefficient, as …

  8. java - Add String Array to ArrayList - Stack Overflow

    is it posible to add more arrays in list in the same line of the code, something like aList.addAll(Arrays.asList(question1,question2,question3...)); – GlacialMan Commented Apr …

  9. java - How can I add a string to an array? - Stack Overflow

    Feb 23, 2015 · LIMIT, in this case, is a constant you should create with the size of your list. Initilize your option[] in your class constructor. Your method addTo() should only add the String …

  10. Append a single character to a string or char array in java?

    First of all you use here two strings: "" marks a string it may be ""-empty "s"- string of lenght 1 or "aaa" string of lenght 3, while '' marks chars . In order to be able to do String str = "a" + "aaa" + …

Refresh