Difference between HashSet and TreeSet in Java

Difference between HashSet and TreeSet in Java
There are several differences between an HashSet and a TreeSet is similar to what we discussed as a difference between TreeMap and HashMap. Anyway, Set and Map are two completely different interfaces so we will revisit those differences here. Probably the most important difference between HashSet and TreeSet is the performance. HashSet is faster than TreeSet which means if you need performance use HashSet but HashSet doesn't provide any kind of ordering so if you need ordering then you need to switch to TreeSet which provides sorting of keys. Sorting can be natural order defined by a Comparable interface or any particular order defined by Comparator interface in Java.

How to convert Vector to array in Java? 2 Examples

In the last article, we have learned how to convert a LinkedList to array in Java and in today's tutorial you will learn how to convert a Vector to array in Java. There is a similarity between Vector and LinkedList, both implements the List interface. Even though Vector is a legacy class and exists in Java from JDK 1.1 long before Java Collection framework was introduced, it was later retrofitted to implement the List interface. You can use the same toArray() method to convert a Vector to an array in Java. Similar to LinkedList, you can convert Vector of any object to an array of the corresponding object, the only restriction is that you cannot convert a vector of Integers to an array of ints or Vector of Float objects to an array of floats, which applies to our linked list solution as well.

Top 20 Hibernate Interview Questions for Java J2EE Programmers

Hibernate is one of the most popular persistent frameworks in Java world. Hibernate offers object to relational (ORM) solution which frees Java developers from writing tedious, hard to read and cluttered JDBC code converting SQL columns into Object properties. Apart from freeing Java developer from writing JDBC and database interaction code, Hibernate also offers the out-of-box solution on caching, proxying and lazy loading which drastically improves the performance of your Java Web application. Given it's important in Java Web application development field Hibernate has become of one of the  most sought after skill and goes hand in hand with Spring framework. That's why Hibernate interview questions are also very popular in Java interviews. Earlier I have shared some Spring MVC interview questions and due to popular demand, I am now sharing 20 odd Hibernate questions from various Java interviews.