Raja has Published 760 Articles

How to convert a JSON to Java Object using the Jackson library in Java?

raja

raja

Updated on 07-Sep-2023 00:47:49

36K+ Views

The ObjectMapper class is the most important class in the Jackson library. We can convert a JSON to Java Object using the readValue() method of ObjectMapper class, this method deserializes a JSON content from given JSON content String.Syntaxpublic readValue(String content, JavaType valueType) throws IOException, JsonParseException, JsonMappingExceptionExampleimport java.io.*; import java.util.*; import ... Read More

When to use an abstract class and when to use an interface in Java?

raja

raja

Updated on 02-Sep-2023 15:58:43

39K+ Views

An interface can be used to define a contract behavior and it can also act as a contract between two systems to interact while an abstract class is mainly used to define default behavior for subclasses, it means that all child classes should have performed the same functionality.When to use ... Read More

How can we read a JSON file in Java?

raja

raja

Updated on 02-Sep-2023 12:55:51

51K+ Views

The JSON is one of the widely used data-interchange formats and is a lightweight and language independent. The json.simple is a lightweight JSON processing library that can be used to read and write JSON files and it can be used to encode or decode JSON text and fully compliant with JSON specification (RFC4627). In order to read ... Read More

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

raja

raja

Updated on 15-Jul-2020 04:59:08

126 Views

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 ... Read More

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

raja

raja

Updated on 15-Jul-2020 04:58:24

64 Views

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 ... Read More

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

raja

raja

Updated on 15-Jul-2020 04:56:16

86 Views

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 ... Read More

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

raja

raja

Updated on 14-Jul-2020 13:58:35

124 Views

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;; ... Read More

How to implement DoubleToIntFunction using lambda expression in Java?

raja

raja

Updated on 14-Jul-2020 13:55:31

195 Views

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) ... Read More

How to implement DoubleToLongFunction using lambda expression in Java?

raja

raja

Updated on 14-Jul-2020 13:54:53

158 Views

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; ... Read More

How to declare a variable within lambda expression in Java?

raja

raja

Updated on 14-Jul-2020 13:53:51

2K+ Views

A lambda expression is a function that expects and accepts input parameters and produces output results. It is an instance of a functional interface and also known as a single abstract method interface (SAM interface) like Runnable, Comparator, Callable and etc. We can declare a variable as a final string[] array and able to access that array ... Read More

Advertisements