Dozer mapper simple example

Lets see Dozer mapper simple example, where we will map a java object into another using the DozerBeanMapper class. Dozer mapper simple example We will have SourceBean and a DestinationBean. Both of them will have similar variables. We will use the Dozer

Read More

How to Setup Dozer Mapper

Imagine a POJO that has lot of member variables and you need to map this object into a new java object. For this you will need to manually write setter for the new object taking values from old object. Dozer mapper makes

Read More

Exception Chaining in Java

Exception chaining in java allows us to relate one exception to another exception. An application often responds to an exception by throwing another exception. In effect, the first exception causes the second exception. It can be very helpful to know when one

Read More

Difference between Throw and Throws in Exception Handling

We have seen examples of Throw and Throws in some of our previous posts. Throw and Throws keyword are used in different scenarios while doing exception handling. In this post we see some basic difference between Throw and Throws. Difference between Throw

Read More

Difference Between HashSet LinkedHashSet and TreeSet

HashSet, LinkedHashSet and TreeSet are all implementations of the Set interface.In this post lets see Difference Between HashSet LinkedHashSet and TreeSet. 1. Implementation All these 3 implement the Set interface. HashSet is backed by a hash table (actually a HashMap instance). LinkedHashSet

Read More

TreeSet Example in Java

TreeSet is a NavigableSet implementation based on a TreeMap. Sorting in the TreeSet makes it different from the HashSet. In TreeSet the elements are sorted ascending using their nartural sorting order. You can change the sorting by providing a Comparator while constructing

Read More

LinkedHashSet Example in Java

LinkedHashSet extends the HashSet and is the implementation of Hash Table and Linked List. LinkedHashSet maintains a doubly-linked list through all of its elements. This helps in maintaining the insertion-order of the elements. Since LinkedHashSet extends the HashSet, they have all the

Read More

Merging Cells in Excel Using POI

Merging Cells in Excel using POI can be done using the [crayon-5a66e2fc2d84b223215194-i/] method. CellRangeAddress is the range of the rows and columns that need to be selected. In our case to be merged. The constructor of CellRangeAddress takes 4 params – [crayon-5a66e2fc2d857917256483-i/]

Read More

User Defined Exceptions in Java

While working on an application, you may come across some scenarios where you feel like the Exceptions defined in the java platform are not enough to represent the error/issue you want to tell the end user. In that case you may choose

Read More

Sorting TreeMap Using Comparator

TreeMap are sorted naturally using their Keys. If you have your objects as keys then Sorting TreeMap using Comparator is a good way to decide the map order. Lets see an example on how to use Comparator in a TreeMap 1. User

Read More