Here, we will create a function that will delete all elements of a linked list one by one.In c/c++, there is no specific function to perform this task but in java, the automatic garbage collection is done to ease deleting linked list.Now, let’s see the implementation of this program, Example Live Demo#include using namespace std; class Node{ public: int data; Node* next; }; void deleteLinkedList(Node** head_ref){ Node* current = *head_ref; Node* next; while (current != NULL){ coutnext = (*head_ref); (*head_ref) = new_node; } int main(){ Node* head = NULL; ... Read More
LongToIntFunction is a functional interface from java.util.function package introduced in Java 8. This functional interface accepts a long-valued parameter as input and produces an int-valued result. LongToIntFunction interface can be used as an assignment target for a lambda expression or method reference. This interface contains only one abstract method: applyAsInt() and doesn't contain any default and abstract methods.Syntax@FunctionalInterface interface LongToIntFunction { int applyAsInt(long value); }Example of Lambda Expressionimport java.util.function.LongToIntFunction; public class LongToIntLambdaTest { public static void main(String args[]) { LongToIntFunction getInt = longVal -> { // lambda expression int intVal = (int)longVal; ... Read More
LongToDoubleFunction is a built-in functional interface and part of java.util.function package. This functional interface accepts a long-valued parameter as input and produces a double-valued result. LongToDoubleFunction can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsDouble().Syntax@FunctionalInterface interface LongToDoubleFunction { double applyAsDouble(long value); }Example of Lambda Exampleimport java.util.function.LongToDoubleFunction; public class LongToDoubleLambdaTest { public static void main(String args[]) { LongToDoubleFunction getDouble = longVal -> { // lambda expression double doubleVal = longVal; return doubleVal; }; long input = ... Read More
IntToLongFunction is a built-in functional interface from java.util.function package. This functional interface accepts an int-valued parameter and produces a long-valued result. IntToLongFunction interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsLong().Syntax@FunctionalInterface interface IntToLongFunction { long applyAsLong(int value); }Example of Lambda Expressionimport java.util.function.IntToLongFunction; public class IntToLongFunctionLambdaTest { public static void main(String args[]) { IntToLongFunction getLong = intVal -> { // lambda expression long longVal = intVal; return longVal; }; int input = 40; ... Read More
In order to disable future dates, you need to use maxDate and set the current date. Following is the JavaScript code −Example Live Demo Document The selected date is as follows: $(document).ready(function () { var currentDate = new Date(); $('.disableFuturedate').datepicker({ format: 'dd/mm/yyyy', autoclose:true, endDate: "currentDate", maxDate: currentDate }).on('changeDate', function (ev) { $(this).datepicker('hide'); }); $('.disableFuturedate').keyup(function () { ... Read More
For this, you need to use keyDown as well as preventDefault(). Following is the JavaScript code −Example Live Demo Document const pressEnter = (event) => { if (event.key === "Enter") { event.preventDefault(); } }; document.getElementById("disableDefaultTime").addEventListener("keydown", pressEnter); To run the above program , just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode editor.OutputFollowing is the output. When you press Enter key nothing will be displayed.You need to use keyDown to get time as in the below screenshot −
For this, you need to use attr(). The attr() method can be used to either fetch the value of an attribute from the first element in the matched set or set attribute values onto all matched elements.Following is the JavaScript code −Example Live Demo Document $('#myURL').attr('value', 'http://www.facebook.com'); To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode Editor.OutputLook at the above sample output the URL has been changed ... Read More
IntToDoubleFunction is a functional interface from java.util.function package. This functional interface accepts an int-valued argument and produces a double-valued result. IntToDoubleFunction can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsDouble().Syntax@FunctionalInterface interface IntToDoubleFunction { double applyAsDouble(int value); }Example of Lambda Expressionimport java.util.function.IntToDoubleFunction;; public class IntToDoubleLambdaTest { public static void main(String[] args) { IntToDoubleFunction getDouble = intVal -> { // lambda expression double doubleVal = intVal; return doubleVal; }; int input ... Read More
DoubleToIntFunction is a functional interface defined in java.util.function package introduced in Java 8 version. This functional interface accepts a double-valued argument and produces an int-valued result. DoubleToIntFunction interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsInt().Syntax@FunctionalInterface interface DoubleToIntFunction { int applyAsInt(double value) }Exampleimport java.util.function.DoubleToIntFunction; public class DoubleToIntFunctionTest { public static void main(String args[]) { DoubleToIntFunction test = doubleVal -> { // lambda expression int intVal = (int) doubleVal; return intVal; }; ... Read More
DoubleToLongFunction is a built-in functional interface from java.util.function package introduced in Java 8. This functional interface accepts a double-valued parameter and produces a long-valued result. DoubleToLongFunction interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsLong().Syntax@FunctionalInterface public interface DoubleToLongFunction { long applyAsLong(double value) }Exampleimport java.util.function.DoubleToLongFunction; public class DoubleToLongFunctionTest { public static void main(String args[]) { double dbl = 30.1212; DoubleToLongFunction castToLong = (dblValue) -> (long) dblValue; // lambda expression System.out.println(castToLong.applyAsLong(dbl)); dbl = 77.9212; DoubleToLongFunction roundToLong = Math::round; ... Read More