Default Method

Need for default method- Without effecting implementation classes if we want to add new method to the interface then we can do this with default interface. Syntax:

Output: Default Method Suppose if we want to provide new implementation then we can do this as well. This can be done as…

Continue reading

Lamda_SquareExample

Lamda Expression example for square of int :

Output: Square of 2 is :4 now suppose we put parenthesis in the body as below and try to compile the code using command prompt,

you will get compilation error as below: \basic>javac Lamda_SquareExample.java Lamda_SquareExample.java:13: error: not a statement Interfun…

Continue reading

Lamda_AddExample

Example of Lamda Expression for addition of two int.

Output: Sum is:30 Sum is:300 Similar posts: Java 8 Features Functional Interface Lamda Expression

Continue reading

Lamda Expression

Lamda Expression: Ealier for a function few things were mandatory,such as 1>Access Modifier. 2>Return statement. 3>Name Eg:

  But for a Lamda expression these things are not required,so the above function is written as:

  The Operator that is used to denote the lamda expression is -> Now…

Continue reading

Functional Interface

An Interface which has only one abstract method is known as Functional Interface. It can have any number of default and static method but only one abstract method is allowed. @FunctionalInterface is the annotation used to forcefully tell the compiler that the interface is a FunctionalInterface. Sample code: package com.technicalstack.basic;…

Continue reading

Java 8 Features

Some of the important Java 8 features are; Functional Interfaces and Lambda Expressions default and static methods in Interfaces forEach() method in Iterable interface Java Stream API for Bulk Data Operations on Collections Java Time API Collection API improvements Concurrency API improvements Java IO improvements Similar posts: Top Java Questions…

Continue reading