Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

add string to array java

in java, once you declared an array you cannot change its size.
so that adding an element to the array is not possible.
you can declare an arraylist, which is the same as array but its resizable.
meaning that you can add or remove at any time and as much you want.
for example:
ArrayList<String> languages = new ArrayList<String>(); 
languages.add("PHP");
languages.add("JAVA");
languages.add("C#");
ArrayList<int> numbers = new ArrayList<int>(); 
numbers.add(9);
numbers.add(14);
numbers.add(2);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #string #array #java
ADD COMMENT
Topic
Name
5+2 =