ReentrantLock in Java With Examples

ReentrantLock in Java is part of java.util.concurrent.locks package with in the Java concurrency API added in Java 5 which also has other classes like ConcurrentHashMap, CountDownLatch. ReentrantLock class in Java implements java.util.concurrent.locks.Lock interface and provides many locking operations. Table of contents ReentrantLock in Java Concurrency Why call it a ReentrantLock…

Continue reading

Java Spliterator With Examples

Spliterator in Java, just like Iterator and ListIterator, is used for traversing the elements of a source. How it differs from other iterator implementation is that the Spliterator API is designed to support efficient parallel traversal in addition to sequential traversal. Using Spliterator elements can be partitioned and iterated in…

Continue reading

Java Stream Collectors summingInt(), summingLong(), summingDouble()

In the tutorial Java Stream Collectors averagingInt(), averagingLong(), averagingDouble() we saw how Collectors class in Java Stream API provides methods like Collectors.averagingInt(), Collectors.averagingLong(), Collectors.averagingDouble() to get average of Stream on Integers, Long and Double respectively. Same way if you want to quickly add the stream elements there are Collectors.summing() methods…

Continue reading

Java Stream Collectors averagingInt(), averagingLong(), averagingDouble()

If you want average of Stream elements there are handy utility methods available in Collectors class to quickly do that, the methods are- Collectors.averagingInt()- To get average of stream of integers. Collectors.averagingLong()- To get average of stream of longs. Collectors.averagingDouble()- To get average of stream of doubles. Collectors.averaging methods in…

Continue reading