java.util.ConcurrentModificationException

java-thumbnail

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 Dictionary Example

java-thumbnail

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

java-thumbnail

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

java-thumbnail

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 […]

How To Display Currency For A Locale In Java

java-thumbnail

This example demonstrates how to get currency name for the given locale. This would be very useful for the programmers when you want to display the amount prefixed with the currency symbol dynamically for different countries. You can get the currency object for a given locale by calling Currency.getInstance(locale) method. This returns the currency object which […]

StringTokenizer Example

java-thumbnail

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

java-thumbnail

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 […]

Close
Please support the site
By clicking any of these buttons you help our site to get better