JDK   8
This presentation is the property of its rightful owner.
Sponsored Links
1 / 14

Introduction to JDK 8 PowerPoint PPT Presentation


  • 82 Views
  • Uploaded on
  • Presentation posted in: General

JDK 8. Introduction to JDK 8. Agenda. JDK 8 - Composition. Second part of Plan B. Lambda. Project Jigsaw. Project Coin. ++. ++. Lambda Expressions. An anonymous function with argument list, return type and a body. (argument list) arrow_operator { java_statements }

Download Presentation

Introduction to JDK 8

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introduction to jdk 8

  • JDK 8

Introduction to JDK 8


Introduction to jdk 8

  • Agenda


Introduction to jdk 8

  • JDK 8 - Composition

Second part of Plan B

Lambda

Project Jigsaw

Project Coin

++

++


Introduction to jdk 8

  • Lambda Expressions

An anonymous function with argument list, return type and a body.

(argument list) arrow_operator { java_statements}

(int, int) -> { x+y}

[ ] A definitive epitome programming style dating back to lisp style programming.

[ ] Instances of Functional Interfaces.

[ ] Lexically scoped programming style.


Introduction to jdk 8

  • java.util.function

java.lang.FunctionalInterface

Function

Predicate

Consumer

IntToLongFunction

BooleanSupplier

A programming paradigm

Also called, SAM (Single Abstract Method)


Introduction to jdk 8

  • Usage of Lambda Expressions

Runnable runnable = () -> {

System.out.println("Richard Feynman !!! ");

};

runnable.run();

interface java.lang.Runnable {

void run();

}

interface java.lang.Iterable<T> {

java.util.Iterator<T> iterator();

}

interfacejava.util.concurrent.Executor{

voidexecute(java.lang.Runnable command);

}

interfacejava.awt.event.ActionListener{

voidactionPerformed(java.awt.event.ActionEvent e);

}

Now a functional interface !!!


Introduction to jdk 8

  • Internal Iteration

Use the forEach

List listOfStrings = new ArrayList<String>();

listOfStrings.add("alan");

listOfStrings.add("mathison");

listOfStrings.add("turing");

listOfStrings.forEach(x -> System.out.println(x));


Introduction to jdk 8

  • API’s

java.util.Optional<T>

Optional<Chola> op = Optional.empty();

Optional<Chola> op = Optional.of(new Chola("Karikala"));

op.isPresent();

Chola s = op.orElse(new Chola("Raja Raja"));

s.getName();

class Chola extends King

{

String name = "default";

public Chola(String _name) {

name = _name;

}

String getName() {

return name;

}

}


Introduction to jdk 8

  • API’s

Arrays.asList(stringArray).stream() .filter(s -> s.startsWith("1"))

.forEach( s -> { System.out.println(s); });

Arrays.asList(stringArray).parallelStream()

.filter(s -> s.startsWith("2"))

.forEach( s -> { System.out.println(s); });

Arrays.asList(stringArray).stream() .distinct()

.forEach( s -> { System.out.println(s); });


Introduction to jdk 8

  • API’s

Java.util.StringJoiner

StringJoinersj = new StringJoiner("/","<",">");

also,

StringJoinersj = new StringJoiner("/");

sj.add("Chera");

sj.add("Chola");

sj.add("Pandya");

sj.add("Dhara");

sj.toString()

Output

<Chera/Chola/Pandya/Dhara>


Introduction to jdk 8

  • Virtual Extension Methods

public interface DorothyInterface {

default String getName(String name) {

return name + "Wizard";

}

}


Introduction to jdk 8

JDK 5 Tiger

JDK 6 Mustang

JDK 7 Dolphin

JDK 8 no code name yet…


Introduction to jdk 8

“That’s not a mistake” - Mark Reinhold

JDK 9

  • Multi core scalability

  • Big data support

  • Hypervisor Integration

  • Multi – gigabyte heaps

  • Project Jigsaw

  • ...


  • Login