« Back
package com.collection.programs; import java.util.ArrayList; import java.util.List; public class ArrayListDemo { public static void main(String args[]) { List
list = new ArrayList
(); System.out.println(list); System.out.println(list.size()); System.out.println(list.isEmpty()); list.add(10); System.out.println(list.isEmpty()); list.add(3); System.out.println(list.contains(10)); System.out.println(list); list.add(2 ,5); System.out.println(list); list.set(2, 6); System.out.println(list); list.add(2, 8); System.out.println(list); List
list1 = new ArrayList
(list); list1.add(10); list1.add(4); list1.add(3); list1.add(5); System.out.println(list1); list1.removeAll(list); System.out.println(list1); list1.retainAll(list); System.out.println(list); } }
[]
0
true
false
true
[10, 3]
[10, 3, 5]
[10, 3, 6]
[10, 3, 8, 6]
[10, 3, 8, 6, 10, 4, 3, 5]
[4, 5]
[10, 3, 8, 6]
×
Report a Problem:
Description:
Submit