Sunday, 23 August 2015

Difference between Comparator and Comparable in Java

Here are main difference between Comparator and Comparable in Java :

1) Comparable is used to define natural order of object in Java e.g. numeric order for numbers, lexicographic order for String etc, and Comparator is used to define custom order which in addition of default ordering provided by Comparable e.g. default ordering for an Employee class could be by name or id, but you can provide additional Comparator to compare them by salary, age and branch.

Monday, 3 August 2015

What are the difference between Having and Where Clause?

Here are some useful difference between WHERE and HAVING clause in SQL :

1) WHERE clause can be used with SELECT, UPDATE and DELETE statements and  clauses but HAVING clause can only be used with SELECT statements.


SELECT * FROM Employee WHERE EmployeeId=3

will print details of employee with id = 3.