Category Archives: Java

Java – Spring to inject multiple service instances having same interface

Create service for multiple name providers NameService class can inject multiple NameProviders with the following constructor injection. Advertisements

Posted in Java, Programming | Leave a comment

Java – Importance of final fields for immutable object

Java will guarantee that all thread will see correct values of final fields that were set by the constructor, regardless of how object is published.

Posted in Java, Programming | Leave a comment

Java – Open addressing hash implementation in Java

IdentityHashMap class

Posted in Java, Programming | Leave a comment

Java – headMap, tailMap and subMap in NavigableMap

NavigableMap collection on Java provide methods to return the view of Map on sorted order of key. The most common methods are headMap, tailMap and subMap. headMap example. output If inclusive is true on calling headMap(“3”, true), it will be … Continue reading

Posted in Java, Programming | Leave a comment

Java – Java 8 Comparator to replace Guava compound comparing

Guava example Java 8 example

Posted in Java, Programming | Leave a comment

Java – Guava API to implement compareTo with considering sorting ordering

Example of a chained comparison statement.

Posted in Java, Programming | Leave a comment

Java – The article of Stream API under the hood

The following article is explaining the under the hood Java 8 Stream API. https://www.ibm.com/developerworks/library/j-java-streams-3-brian-goetz/index.html

Posted in Java, Programming | Leave a comment