- Trending Categories
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
Maruthi Krishna has Published 951 Articles
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
6K+ Views
The replaceAll() method of the String class accepts two strings representing a regular expression and a replacement String and replaces the matched values with given String.Following is the regular expression to match the leading zeros of a string −The ^0+(?!$)";To remove the leading zeros from a string pass this as ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
757 Views
An interface in Java is similar to class but, it contains only abstract methods and fields which are final and static. Just like classes you can extend one interface from another using the extends keyword as shown below:interface ArithmeticCalculations { public abstract int addition(int a, int b); public ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
451 Views
When you have created an array of a particular data type with fixed size and populate it if you store a value other than its datatype an ArrayStoreException is thrown at the run time.ExampleIn the following Java program, we are creating an Integer array and trying to store a double ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
297 Views
When you are working with collection objects, while one thread is iterating over a particular collection object, if you try to add or remove elements from it, a ConcurrentModificationException will be thrown.Not only that, If you are iterating a collection object, add or remove elements to it and try to ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
3K+ Views
The HashMap is a class that implements the Map interface. It is based on the Hash table. It allows null values and null keys.You can store key-value pairs in the HashMap object. Once you do so you can retrieve the values of the respective keys but, the values we use ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
795 Views
The add() method of the ArrayList class helps you to add elements to an array list. It has two variants −add(E e) − This method accepts an object/elements as a parameter and adds the given element at the end of the list.public void add(int index, E element) − This method ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
20K+ Views
The contains a () method of the String class accepts Sting value as a parameter, verifies whether the current String object contains the specified string and returns true if it does (else false).Therefore, to for a string in an ArrayList −Get the array list.Using the for-each loop get each element ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
770 Views
The ArrayList class in Java is a Resizable-array implementation of the List interface. It allows null values.The clear() method this class removes all the elements from the current List object.Example Live Demoimport java.util.ArrayList; public class ClearExample { public static void main(String[] args){ //Instantiating an ArrayList object ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
985 Views
Java provides Iterator and ListIterator classes to retrieve the elements of the collection objects.The hasNext() methodThe hasNext() method of these interfaces returns true if the collection object has the next element else it returns false.Example Live Demoimport java.util.ArrayList; import java.util.Iterator; public class hasNextExample{ public static void main(String[] args){ ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
Maruthi Krishna
376 Views
The interface set does not allow duplicate elements. The add() method of this interface accepts elements and adds to the Set object, if the addition is successful it returns true if you try to add an existing element using this method, the addition operations fails to return false.Therefore, to remove ... Read More