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 String replace Method With Examples

In Java String class there are four replace methods to replace occurrences of character or string with another character or string. String replace(char oldChar, char newChar)– Returns a string resulting from replacing all occurrences of oldChar in this string with newChar. See example. String replace(CharSequence target, CharSequence replacement)– Replaces each…

Continue reading