Function and BiFunction are the functional interfaces introduced from java 8. Simples examples are as below.
Thursday, 22 April 2021
Wednesday, 21 April 2021
Java: forEachRemaining() method
The forEachRemaining() method is introduced in java 8 itself. This method makes iteration on iterator very easy. Basically, this method uses a lambda expression and reduces a lot of unnecessary code. Check below example,
Java: join() method
The join() is used to hold the execution of the main thread for the time our thread on which we are calling join() method is completed. A simple example of this join() method is as below,
Java: clone() method
The clone() method is used to create a copy of any class which implements the Clonable interface. If the class does not implement the Clonable interface and you still call clonable on that then it will throw ClassNotSupportedException. When we call this clone method then the copy of primitive types will be created but object references will be copied as they are. So basically original and cloned object will have the same object references. So modification in the cloned object will be reflected in the original object.
Shallow copy example,
Tuesday, 20 April 2021
Java: yield() method
The yeild() method gives chance to other high-priority threads to execute. This is one of the static native method from the Thread class.
When we call Thread.yield() in any of the running thread then the currently running thread will move to the ready state and other thread with higher priority will get a chance to execute. If another waiting thread doesn't have a higher priority than the current thread then, in that case, the current thread will continue its execution.
The Explanation from Thread class is,
Example of yield method,
-
Here I am trying to put some variations of printf statement in C language. These are not all, so lets share the other variations that you k...
-
1. The "contenteditable" attribute is used to... a) Update content dynamically from server. b) Allow the user to edi...
-
This is one of the useful class in java which is present in java.lang package. We can't instantiate this class manually means we can...