- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to remove an element from an array in Java
Following example shows how to remove an element from array.
Example
import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList objArray = new ArrayList(); objArray.clear(); objArray.add(0,"0th element"); objArray.add(1,"1st element"); objArray.add(2,"2nd element"); System.out.println("Array before removing an element"+objArray); objArray.remove(1); objArray.remove("0th element"); System.out.println("Array after removing an element"+objArray); } }
Output
The above code sample will produce the following result.
Array before removing an element[0th element, 1st element, 2nd element] Array after removing an element[2nd element]
- Related Articles
- How to remove an element from ArrayList in Java?
- How to remove an element from Array List in C#?
- How to remove an element from a Java List?
- How to delete/remove an element from a C# array?
- How to remove every Nth element from an array JavaScript?
- Remove an element from IdentityHashMap in Java
- How to remove an element from ArrayList or, LinkedList in Java?
- Java program to remove the duplicate element in an array
- Remove an element from a Queue in Java
- Remove an element from a Stack in Java
- Java Program to Remove Repeated Element from An ArrayList
- Remove an element from an ArrayList using the ListIterator in Java
- MongoDB query to match and remove element from an array?
- How do I remove a particular element from an array in JavaScript
- Use Iterator to remove an element from a Collection in Java

Advertisements