java--ArrayList

ArrayList(集合)

createDemo:

                ArrayList<String> array = new ArrayList<String>();

addDemo:

                array.add("hello");  // ["hello"]
		        array.add("world");  // ["hello","world"]
		        array.add(1,"android"); //["hello","android","world"]

getDemo:

                array.get(1); // "android"

sizeDemo:

                array.size();  // 3

removeDemo:

                array.remove("abcde");  // false
		        array.remove(1);  // "android",   ["hello","world"]

setDemo:

                array.set(1,"android");  // "world"  ["hello", "android"]
posted @ 2019-06-21 11:26  it-pupil  阅读(204)  评论(0编辑  收藏  举报