
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

266 Views
An Optional class provides a container that may or may not contain a non-null value. This Optional class introduced in Java 8 to reduce the number of places in the code where a NullPointerException can be generated. Java 9 added three new methods to Optional class: or(), ifPresentOrElse() and stream() that help us to deal with default values.Optional.or()The or() method introduced in Java 9 and the parameter of this method is a functional interface Supplier. This method always gives us an Optional object that is not empty. If the Optional object is not empty, it returns the Optional object itself. Otherwise, it returns an Optional ... Read More

1K+ Views
Java 9 added a new feature of private methods to an interface. The private methods can be defined using a private modifier. We can add both private and private static methods in an interface from Java 9 onwards.Rules for private methods in an interface:A private method has a body in an interface means that we can’t be declared as a normal abstract method as usually do in an interface. If we are trying to declare a private method without a body then it can throw an error says that "This method requires a body instead of a semicolon".We can't be used both private and abstract modifiers together in an interface.If ... Read More

244 Views
Oracle has released Java 9 version with a rich set of new features and brings a lot of new enhancements.Below are a few important features and enhancements introduced in Java 9.Factory Methods for Collections: Factory methods are special kinds of static methods that can be used to create unmodifiable instances of collections, which means we can use these methods to create a list, set, and map.Java Platform Module System (JPMS): A Java Module is a mechanism to bundle java applications and java packages into a Java module. It specifies which of the java packages that contain visible to other java modules by using ... Read More

138 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 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

216 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 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

469 Views
ArrayBlockingQueue stores elements in FIFO order. Insertion of element always happened at the tail of the queue and removal of the element always happened from the head of the queue. It is thread safe and It is bounded array queue therefore once created, the capacity cannot be changed. It is the implementation of the Blocking queue.As per Java Docs −Resizable-array implementation of the Deque interface. Array deques have no capacity restrictions; they grow as necessary to support usage. They are not thread-safe; in the absence of external synchronization, they do not support concurrent access by multiple threads. Null elements are ... Read More

459 Views
OAuth is designed for providing authorization of the third party without providing password. It is http based. OAuth provides an access token that can be exchanged for any supported assertion via an API.OpenId is designed for authentication. In openId third-party authenticate your users for you, by using accounts they already have. It is used to authenticate single sign-on identitySr. No.KeyOAuthOpenId1BasicOAuth is designed for providing authorization of the third party without providing passwordOpenId is designed for authentication.2SessionIt does not initiate user's session.OpenId initiate user's session3Access TokenIt used token concept to provide authorizationIn openId third-party authenticate your users for you, by using ... Read More

167 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 IntToLongFunctionLambdaTest { public static void main(String args[]) { IntToLongFunction getLong = intVal -> { // lambda expression long longVal = intVal; return longVal; }; int input = 40; ... Read More

214 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;; public class IntToDoubleLambdaTest { public static void main(String[] args) { IntToDoubleFunction getDouble = intVal -> { // lambda expression double doubleVal = intVal; return doubleVal; }; int input ... Read More

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 index within a lambda expression.Exampleimport java.util.*; public class LambdaTest { public static void main(String args[]) { final String[] country = {null}; List cities = new ArrayList(); cities.add("Hyderabad"); cities.add("Ireland"); cities.add("Texas"); ... Read More