All three lines below compiled, are there any differences? If not, is it a good Java practice to always stick to the first one as it has the least amount of code?
Map<String, String> m = new HashMap();
Map<String, String> k = new HashMap<>();
Map<String, String> l = new HashMap<String, String>();
And I don't understand why PriorityQueue without <> doesn't compile when I supplied the comparator lambda:
PriorityQueue<Integer> pq = new PriorityQueue(); // compiled
PriorityQueue<Integer> pq = new PriorityQueue((x, y) -> (y - x)); // failed to compile
PriorityQueue<Integer> pq = new PriorityQueue<>((x, y) -> (y - x)); // compiled