Java Cracker

-by Kausik Jana

Difference between Comparable and Comparator interface in Java

In this topic, We will discuss about the difference between Comparable and Comparator interface

    1. Comparable interface resides in java.lang package while Comparator interface resides in java.util package.

    Continue reading

Sorting List of Objects using Comparator Interface in Java

In this topic, we will discuss about the Comparator interface. The Comparator interface defines two methods compare() and equals(). The compare() method compares two objects for order.

Continue reading

Sorting List of Objects using Comparable Interface in Java

In this topic, it shows that how we can sort List of Objects using Comparable interface. Lets have an example of list of employee objects and we have to sort employee based on the employee id in ascending and descending order.

Continue reading

Configure Session Timeout in Java Web Application

There are two ways to configure session time out in Web Application using java.

1. Configure session timeout in web.xml (declarative)

Continue reading

String in switch statements with example

We know switch statement works with primitive types(int, short, byte) or enum constants. Java 7 introduced switch case with “String“.

Continue reading

Importance of hashCode() and equals() methods

While we are working with objects in collection framework, we need to consider the followings:

  • Set doesn’t allow duplicate value.
  • Map uses the key object which can’t duplicate

Continue reading

« Older posts

© 2014 Java Cracker

Proudly Powered by Wordpress