ConcurrentModificationException is thrown when two threads are updating the same element on same time. This issue occurs often in the multithreaded environment. However, this also can occur in the single thread environment where same application running the multiple threads which updates the same object. Look at this example which throws ConcurrentModificationException while updating the value …
Java Util
Java Dictionary Example
Dictionary class is the abstract class which is parent of any class which uses the key and value pair relationship. The classes like HashTable extends this class for their functionality. Every key and every value is an object. In any one Dictionary object, every key is associated with at most one value. As a rule, the equals method should be used …
Java Iterable and Iterator Interface
One of the most widely used and most common API in Java is iterator for the collections. If we have the list of objects in an array or list objects, the iterator is very useful for iterating the objects without much extra coding. Here we discuss about the comparison of two key interfaces, Iterable and …
Comparable vs Comparator Interface in Java
This is an interesting topic in Java and can be confusing to many Java developers. So I plan to give some common examples to illustrate the differences. Going by the topic name, these things are obvious to us: Both comparator and comparable are Java interfaces. Any class, which needs to use these interfaces, has to …
StringTokenizer Example
StringTokenizer in java.util package is very useful for spliting the length string into the pieces. You can pass a delimeter to the StringTokenizer constructor to split the string where ever that delimeter appeared in the string. If you have not passed any delimeter, by default it splits the string using the empty space in the …
Compressing and Uncompressing File Example in Java
Compressing and Uncompressing of the files is one of the common utility we use in our daily life. If you are using windows, using WinZip is very common to compress the files and sent to others. The advantage of compressing the files is to save the memory occupied for the file in the disk. It …