Raja has Published 760 Articles

How to implement LongBinaryOperator using lambda and method reference in Java?

raja

raja

Updated on 14-Jul-2020 07:43:00

124 Views

LongBinaryOperator is a part of the functional interface from java.util.function package. This functional interface expects two parameters of type long as the input and produces a long type result. LongBinaryOperator 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 LongBinaryOperator { ... Read More

How to use this and super keywords with lambda expression in Java?

raja

raja

Updated on 14-Jul-2020 07:32:30

1K+ Views

The "this" and "super" references within a lambda expression are the same as in the enclosing context. Since the lambda expression doesn't define a new scope, "this" keyword within a lambda expression signifies "this" parameter of a method where the lambda expression is residing.In the below example, this.toString() calls the toString() ... Read More

How to implement IntConsumer using lambda and method reference in Java?

raja

raja

Updated on 14-Jul-2020 07:31:43

253 Views

IntConsumer interface is a functional interface from java.util.function package in Java 8. This interface accepts a single int-valued argument as input but doesn't produce any output. Since it is a functional interface, it can be used as an assignment target for a lambda expression or method reference. It contains one abstract method: accept() and ... Read More

How to implement DoubleConsumer using lambda expression in Java?

raja

raja

Updated on 14-Jul-2020 06:38:16

196 Views

DoubleConsumer is a functional interface from java.util.function package. This functional interface accepts a single double-valued argument as input and produces no output. This interface can be used as an assignment target for a lambda expression or method reference. DoubleConsumer contains one abstract method: accept() and one default method: andThen().Syntax@FunctionalInterface public interface DoubleConsumer {    void ... Read More

How to implement LongConsumer using lambda in Java?

raja

raja

Updated on 13-Jul-2020 13:29:18

111 Views

LongConsumer is a in-built functional interface from java.util.function package. This interface can accept a single long-valued argument as input and doesn't produce any output. It can also be used as the assignment target for a lambda expression or method reference and contains one abstract method: accept() and one default method: andThen().Syntax@FunctionalInterface public interface LongConsumerExample-1import java.util.function.LongConsumer; ... Read More

How to implement IntUnaryOperator using lambda in Java?

raja

raja

Updated on 13-Jul-2020 13:05:16

679 Views

IntUnaryOperator represents a functional interface that takes an int value and returns another int value. It is defined in java.util.function package and used as an assignment target for a lambda expression or method reference. It contains one abstract method: applyAsInt(), two default methods: compose(), andThen() and one static method: identity().Syntax@FunctionalInterface public interface IntUnaryOperatorExampleimport java.util.function.IntUnaryOperator; public class IntUnaryOperatorLambdaTest1 ... Read More

How to write lambda expression code for SwingUtilities.invokeLater in Java?

raja

raja

Updated on 13-Jul-2020 13:02:57

562 Views

An event handling code that runs on a special thread called event dispatch thread(EDT). Most of the code that invokes swing methods also runs on this EDT thread. It is necessary because most of swing object methods do not thread-safe. SwingUtilities is a utility class and has one important static method, invokeLater(). This ... Read More

How to implement DoubleBinaryOperator using lambda and method reference in Java?

raja

raja

Updated on 13-Jul-2020 12:28:40

249 Views

DoubleBinaryOperator is a functional interface defined in java.util.function package. It accepts two parameters of type double as input and produces another double value as a result. DoubleBinaryOperator interface can be used as an assignment target for a lambda expression or method reference and has only one abstract method applyAsDouble().Syntax@FunctionalInterface public interface DoubleBinaryOperator {  double applyAsDouble(double left, double right); ... Read More

How to implement the IntPredicate interface using lambda and method reference in Java?

raja

raja

Updated on 13-Jul-2020 12:17:37

268 Views

IntPredicate interface is a built-in functional interface defined in java.util.function package. This functional interface accepts one int-valued argument as input and produces a boolean value as an output. This interface is a specialization of the Predicate interface and used as an assignment target for a lambda expression or method reference. It provides only one abstract method, ... Read More

How to implement ActionEvent using method reference in JavaFX?

raja

raja

Updated on 13-Jul-2020 12:16:32

1K+ Views

The javafx.event package provides a framework for Java FX events. The Event class serves as the base class for JavaFX events and associated with each event is an event source, an event target, and an event type. An ActionEvent widely used when a button is pressed.In the below program, we can implement an ActionEvent for a button by ... Read More

Advertisements