Let’s learn thread setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) method in java. Thread setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) method in java setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) method set the handler invoked when this thread abruptly terminates due to an uncaught exception. Syntax public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) Parameters ueh the object to use as this thread’s uncaught exception handler. If null then this thread has no…

Read More setUncaughtExceptionHandler() Thread method in java

Let’s learn thread setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) method in java. Thread setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) method in java setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) method set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread. Syntax public static void setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) Parameters ueh the object to use as…

Read More setDefaultUncaughtExceptionHandler() Thread method java

Let’s learn thread holdslock(object obj) method in java. Thread holdslock(object obj) method in java holdslock(object obj) method returns true if and only if the current thread holds the monitor lock on the specified object. Thread.holdsLock() method is designed to allow a program to assert that the current thread already holds a specified lock: assert Thread.holdsLock(obj);…

Read More Thread holdslock() method in java

Let’s learn thread getUncaughtExceptionHandler() method in java. Thread getUncaughtExceptionHandler() method in java getUncaughtExceptionHandler() method returns the handler invoked when this thread abruptly terminates due to an uncaught exception. If this thread has not had an uncaught exception handler explicitly set then this thread’s ThreadGroup object is returned, unless this thread has terminated, in which case…

Read More Thread getUncaughtExceptionHandler() method in java

Let’s learn thread getDefaultUncaughtExceptionHandler() method in java. Thread getDefaultUncaughtExceptionHandler() method in java getDefaultUncaughtExceptionHandler() method returns the default handler invoked when a thread abruptly terminates due to an uncaught exception. If the returned value is null, there is no default. Syntax public static Thread.UncaughtExceptionHandler getDefaultUncaughtExceptionHandler() Returns the default uncaught exception handler for all threads Example class…

Read More getDefaultUncaughtExceptionHandler() Thread method in java

Let’s learn HashMap computeIfPresent() method in java. HashMap computeIfPresent(K key, BiFunction <? super K, ? super V,? extends V> remappingFunction) method in java computeIfPresent(K key, BiFunction <? super K, ? super V,? extends V> remappingFunction) method returns the new value associated with the specified key, or null if none. If the value for the specified…

Read More HashMap computeIfPresent() method in java

Let’s learn HashMap computeIfAbsent() method in java. HashMap computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) method in java computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) method returns the current (existing or computed) value associated with the specified key, or null if the computed value is null. If the specified key is not already…

Read More HashMap computeIfAbsent() method in java

Let’s learn TreeSet pollFirst() method in java. TreeSet pollFirst() method in java pollFirst() method retrieves and removes the first (lowest) element, or returns null if this set is empty. Syntax public E pollFirst() Example import java.util.*; class TreeSetPollFirstDemo { public static void main(String[] args) { TreeSet<Integer> ts = new TreeSet<Integer>(); ts.add(1); ts.add(3); ts.add(6); ts.add(15); ts.add(24);…

Read More TreeSet pollFirst() method in java

Let’s learn linkedlist descendingiterator() method in java. LinkedList descendingIterator() method in java descendingIterator() method returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head). Syntax public Iterator<E> descendingIterator() Example import java.util.*; class LinkedListDescendingIteratorDemo { public static void main(String[] args)…

Read More LinkedList descendingIterator() method in java

Let’s learn vector subList(int fromIndex, int toIndex) method in java. Vector subList(int fromIndex, int toIndex) method in java subList(int fromIndex, int toIndex) method returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned List is empty.) The returned List is backed by…

Read More Vector subList() method in java