Raja has Published 469 Articles

Can we have a try block without a catch block in Java?

raja

raja

Updated on 21-Nov-2023 10:08:40

34K+ Views

Yes, It is possible to have a try block without a catch block by using a final block. As we know, a final block will always execute even there is an exception occurred in a try block, except System.exit() it will execute always. Example 1 public class TryBlockWithoutCatch { public static ... Read More

Can we have a return statement in the catch or, finally blocks in Java?

raja

raja

Updated on 17-Nov-2023 16:33:50

15K+ Views

Yes, we can write a return statement of the method in catch and finally block. There is a situation where a method will have a return type and we can return some value at any part of the method based on the conditions. If we return a value in the catch block ... Read More

Can we execute a java program without a main method?

raja

raja

Updated on 07-Oct-2023 02:45:53

31K+ Views

Yes, we can execute a java program without a main method by using a static block.  Static block in Java is a group of statements that gets executed only once when the class is loaded into the memory by Java ClassLoader, It is also known as a static initialization block. ... Read More

How can we read a JSON file in Java?

raja

raja

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

61K+ 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

212 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

136 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

165 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

212 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

342 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

264 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

Previous 1 ... 3 4 5 6 7 ... 47 Next
Advertisements