JDK   8
Download
1 / 14

Introduction to JDK 8 - PowerPoint PPT Presentation


  • 107 Views
  • Uploaded on

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 }

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Introduction to JDK 8' - lilike


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



Second part of Plan B

Lambda

Project Jigsaw

Project Coin

++

++


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.


java.lang.FunctionalInterface

Function

Predicate

Consumer

IntToLongFunction

BooleanSupplier

A programming paradigm

Also called, SAM (Single Abstract Method)


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


Use the forEach

List listOfStrings = new ArrayList<String>();

listOfStrings.add("alan");

listOfStrings.add("mathison");

listOfStrings.add("turing");

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


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;

}

}


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); });


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>


public interface DorothyInterface {

default String getName(String name) {

return name + "Wizard";

}

}


JDK 5 Tiger

JDK 6 Mustang

JDK 7 Dolphin

JDK 8 no code name yet…


“That’s not a mistake” - Mark Reinhold

JDK 9

  • Multi core scalability

  • Big data support

  • Hypervisor Integration

  • Multi – gigabyte heaps

  • Project Jigsaw

  • ...


ad