Skip to main content

Java Comparator Applications

Java Comparator is one of the favourite questions in Java Interviews.

This concept looks deceptively simple, and slight variations of this could be asked in the interviews.


1) Write an AlphaNumeric Comparator in Java that sorts the given strings in the human readable
    format.

 e.g., file1, file2, file 3, file4, file 10

Not like the typical comparator file1, file10




2) Chained Comparator which can be used to join Multiple Comparators


3) Given a List of Employee Objects group the Objects such that all the employees are grouped by
    Department and by Name.


4) Use Java 8 Style Comparators




Comments

Popular posts from this blog

Design Patterns using Java

According to Gang of Four(GOF) any software is classified in to one of the three categories. I read so many books about design patterns which provide a lot of information about Design Patterns in a language neutral way or related to a particular programming language. I am trying to complement the great books by providing the precise and concise information that is required in the day to day programming of a Java Developer. Any software can be classified into one of the three categories -Framework, Toolkit, Application. Framework - Framework defines a set of steps to create an application. Framework provides design reuse. Toolkit - Toolkit provides some utility functions to an existing application. Toolkit provides code reuse. Application - Application is some thing that is specific to the project, and is not useful outside the context of the current application. Gang of Four divided the Design Patterns in to 3 types based on their usage. There are 3 types of Gang of Fo