📜  将字符串添加到数组 java - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:46.650000             🧑  作者: Mango

代码示例4
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 languages = new ArrayList(); 
languages.add("PHP");
languages.add("JAVA");
languages.add("C#");
ArrayList numbers = new ArrayList(); 
numbers.add(9);
numbers.add(14);
numbers.add(2);