Basic Java 8 Features

Cahit Barkin Ozer
8 min readNov 17, 2021

Main Java 8 features: Lambda expressions, Stream API, and Date Time API explained.

Java Stream API with Lambda Operations[9]

For Access: https://cbarkinozer.medium.com/basic-java-8-features-7cfac0b2b8e8?source=friends_link&sk=e133e1f74bb322babced5325d66f4022

Lambda Expressions

Lambda expressions are inline functions. They provide a straightforward and concise approach to use an expression to represent one method interface. It helps to iterate, filter, and extract data from a collection. [1]

We employ lambda expressions in order to give a functional interface with minimal coding.[2]

Syntax[2]:

For a single line of code:

(parameter1, parameter2) -> expression

Or for multiple lines of codes:

(parameter1, parameter2) -> { 
code block
}

Constraints

There are a few limitations for expression. They must return a value immediately and cannot contain variables, assignments, or phrases like if or for. A code block containing curly brackets can be used to do more sophisticated actions..[2]

//Without lambda, Drawable implementation using anonymous classDrawable d=new Drawable(){  public void draw(){

--

--

Cahit Barkin Ozer
Cahit Barkin Ozer

Written by Cahit Barkin Ozer

Üretken YZ başta olmak üzere teknoloji alanındaki yenilikleri öğrenip sizlerle paylaşıyorum. Youtube Kanalım: https://www.youtube.com/@cbarkinozer

No responses yet