- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the method removeRange(int fromIndex, int toIndex) do in java?
The removeRange() method of the ArrayList class removes all of the elements from this List whose index is between fromIndex and toIndex.
Example
import java.util.*; public class ArrayListDemo extends ArrayList{ public static void main(String[] args) { ArrayListDemo arrlist = new ArrayListDemo(); arrlist.add(10); arrlist.add(12); arrlist.add(31); System.out.println("The list:" + arrlist); arrlist.removeRange(0,2); System.out.println("The list after using removeRange:" + arrlist); } }
Output
The list:[10, 12, 31] The list after using removeRange:[31]
Advertisements
To Continue Learning Please Login
Login with Google