import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
// Create a list
List<Integer> list = new ArrayList<>();
for (int i = 1; i <= 10; i++) {
list.add(i);
}
System.out.println("Original List: " + list);
// Define the range to remove (fromIndex inclusive, toIndex exclusive)
int fromIndex = 3;
int toIndex = 7;
// Remove the sublist
list.subList(fromIndex, toIndex).clear();
System.out.println("List after removing sublist: " + list);
}
}
/*
run:
Original List: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
List after removing sublist: [1, 2, 3, 8, 9, 10]
*/