-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMyArrayList.java
37 lines (29 loc) · 1.01 KB
/
MyArrayList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.gaurav.ExProject.ArrayList;
import java.util.ArrayList;
import java.util.List;
/**
* A java program to remove the range of elements from
* the MyArraylist (a class which extends the ArrayList)
* using the removeRange() method.
*
* The removeRange() method is protected and is accessed in class,
* subclasses and in a package, but not public.
*
* @author Gaurav Kukade at coderolls.com
*
*/
public class MyArrayList extends ArrayList<String> {
public static void main(String[] args) {
MyArrayList myArrayList = new MyArrayList();
myArrayList.add("Monday");
myArrayList.add("Tuesday");
myArrayList.add("Wednesday");
myArrayList.add("Thursday");
myArrayList.add("Friday");
myArrayList.add("Saturday");
myArrayList.add("Sunday");
System.out.println("Arraylist before removing range of elments:\n"+ myArrayList);
myArrayList.removeRange(2, 4);
System.out.println("\nArraylist after removing range of elments:\n"+ myArrayList);
}
}