jdk 8 features

Upload: arul-jothi

Post on 01-Jun-2018

241 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 JDK 8 Features

    1/40

    Java 1.8 (JDK8): What's new? Code examples and performance

    In a previous post, I talked about new features and performance of java 1.7. Java 7 has now beenreleased a while ago and Java 8 is coming. Java 1.8 is planned to be released on the 9th of

    eptember !"1#. I$m going to present the main new features of the Java 8 %J&'8(. I will show

    some code e)amples and run some simple benchmarks to compare it with its predecessor Java

    1.* and Java 1.7.

    +ew features in Java 1.8

    I won$t be going through ever single new feature that are going to make it in Java 8 but simpl

    the ones I found being noteworth. -or an e)tensive list, ou can visit the official J&' 8 features

    page. If ou think there is something worth mentioning in m article which I have ommitted then

    leave a comment.

    ere are the new Java 1.8 features I$ll talk about/

    0ambda e)pressions

    emove the 2ermanent 3eneration

    mall 45

    2arallel 6rra orting

    ulk &ata perations for ollections

    &efine a standard 62I for ase*: encoding and decoding

    +ew &ate ; ncrption %2>(

    algorithm implementations in the unJ> provider

    ere are two features that were originall planned but that have been dropped.

  • 8/9/2019 JDK 8 Features

    2/40

    +ew

  • 8/9/2019 JDK 8 Features

    3/40

    tatics method/

    public class ?tils C

    public static int compare0ength%tring in, tring out(Creturn in.length%( = out.length%(H

    public class 5lass C

    public void doomething%( C

    tringK args L new tringK CEmicrosoftE,EappleE,Elinu)E,EoracleE6rras.sort%args, ?tils//compare0ength(H

    +on statics method/

    public class 5lass implements omparableA5bjectB C

    Dverride

    public int compare

  • 8/9/2019 JDK 8 Features

    4/40

    owever that doesn$t mean ou won$t have to worr about the class metadata memor footprint

    and it does not eliminate class and classloader memor leaks.

    5ost allocations for the class metadata are now allocated out of native memor and classes used

    for describing the class metadata are removed.

  • 8/9/2019 JDK 8 Features

    5/40

    parallelort%doubleK a, int fromInde), int toInde)(

    parallelort%floatK a(

    parallelort%floatK a, int fromInde), int toInde)(parallelort%intK a(

    parallelort%intK a, int fromInde), int toInde)(

    parallelort%longK a(parallelort%longK a, int fromInde), int toInde)(

    parallelort%shortK a(

    parallelort%shortK a, int fromInde), int toInde)(parallelort%

  • 8/9/2019 JDK 8 Features

    6/40

    3iven the people&6.find%E0ondonE( will return thousands of 2erson. Fith just one line, I can

    filter that big 0ist to keep onl the 2erson matching mith, 6dams and rawford. verone probabl agrees that ase*: in java EcoreE is bit mess and proabl most resort to use

    the apache ase*: librar %part of apache commons( instead. o this feature is simpl to

    implement a standard 62I for ase*: and to avoid people to have to use unsupported classes

    such as sun.misc.6>*:>ncoder and sun.misc.6>*:&ecoder or apache commons I

    suppose.

  • 8/9/2019 JDK 8 Features

    7/40

    with616nd&>ede %!=ke(

    2>with616nd!W1!8

    6lso 6 algorithms support will be added. o/

    2>Fithmac61 mac

    2>Fithmac6!!: mac

    2>Fithmac6!@* mac

    2>Fithmac6#8: mac

    2>Fithmac6@1! mac

  • 8/9/2019 JDK 8 Features

    8/40

    -or more, check out this pageon java.net.

  • 8/9/2019 JDK 8 Features

    9/40

  • 8/9/2019 JDK 8 Features

    10/40

    J

    7

    Deplo#ment Java We% 3tart 0pplet Java l$;!n

    D2 742 742;22 3cr!pt!n

    Comp

    act

    rof!l

    es

    ther ase

    !%rar!es

    eans

    3ec$r!t#3er!al!9at!

    onxtens!on

    4echan!sm

    J4=

    =4 J0=>etwor!n

    verr!de

    4echan!sm

    J>2Date and

    *!me2np$t$t

    p$t2nternat!onal!9at!

    on

    lan and $t!l

    ase

    !%rar!es

    lan and $t!l

    4athCollect!o

    ns7ef %&ects

    7e$larxpress!ons

    o!n

    4anaement

    2nstr$mentat!on

    Conc$rrenc#

  • 8/9/2019 JDK 8 Features

    11/40

    Mou are viewing a single entr. 2lease also check out the most recent entries.

    5arch !*, !"1#

    >verthing about Java 8

    . It had the best support for the Java 8 language featuresat the time I went looking. Mou can find those builds here/ IntelliJI&>6 >62.

    Interface improvements

    Interfaces can now define static methods. -or instance, a naturalrder method was added tojava.util.omparator/

    public static A< e)tends omparableAR super

  • 8/9/2019 JDK 8 Features

    12/40

    method to an interface would mean breaking all e)isting code that implements the interface. +ow,

    as long as a sensible default implementation of a method can be provided, librar maintainers canadd methods to these interfaces.

    In Java 8, a large number of default methods have been added to core J&' interfaces. I$ll discussman of them later.

    Fh can$t default methods override eNuals, hashode, and totringR

    6n interface cannot provide a default implementation for an of the methods of the bject class. Inparticular, this means one cannot provide a default implementation for eNuals, hashode, or

    totring from within an interface.

  • 8/9/2019 JDK 8 Features

    13/40

    likes.

    6 new annotation, D-unctionalInterface, has been introduced. It can be placed on an interface to

    declare the intention of it being a functional interface. It will cause the interface to refuse to

    compile unless ou$ve managed to make it a functional interface. It$s sort of like Dverridein thiswaH it declares intention and doesn$t allow ou to use it incorrectl.

    0ambdas

    6n e)tremel valuable propert of functional interfaces is that the can be instantiated usinglambdas. ere are a few e)amples of lambdas/

    omma=separated list of inputs with specified tpes on the left, a block with a return on the right/

    %int ), int ( =B C return ) Y H

    omma=separated list of inputs with inferred tpes on the left, a return value on the right/

    %), ( =B ) Y

    ingle parameter with inferred tpe on the left, a return value on the right/

    ) =B ) Z )

    +o inputs on left %official name/ Eburger arrowE(, return value on the right/

    %( =B )

    ingle parameter with inferred tpe on the left, a block with no return %void return( on the right/

    ) =B C stem.out.println%)(H

    tatic method reference/

    tring//valuef

    +on=static method reference/

    bject//totring

    apturing method reference/

    )//totring

    onstructor reference/

    http://docs.oracle.com/javase/8/docs/api/java/lang/FunctionalInterface.htmlhttp://docs.oracle.com/javase/8/docs/api/java/lang/Override.htmlhttp://mail.openjdk.java.net/pipermail/lambda-dev/2012-September/005767.htmlhttp://docs.oracle.com/javase/8/docs/api/java/lang/FunctionalInterface.htmlhttp://docs.oracle.com/javase/8/docs/api/java/lang/Override.htmlhttp://mail.openjdk.java.net/pipermail/lambda-dev/2012-September/005767.html
  • 8/9/2019 JDK 8 Features

    14/40

    6rra0ist//new

    Mou can think of method reference forms as shorthand for the other lambda forms.

    4ethod reference A$!valent lam%da express!on

    tring//valuef ) =B tring.valuef%)(

    bject//totring ) =B ).totring%(

    )//totring %( =B ).totring%(

    6rra0ist//new %( =B new 6rra0istAB%(

    f course, methods in Java can be overloaded. lasses can have multiple methods with the samename but different parameters.

  • 8/9/2019 JDK 8 Features

    15/40

    int ) L @H

    return =B ) Y H

    In order for this lambda declaration to be valid, the variables it captures must be Eeffectivel finalE.

    o, either the must be marked with the final modifier, or the must not be modified after the$re

    assigned.

    Fhether a lambda is capturing or not has implications for performance. 6 non=capturing lambda is

    generall going to be more efficient than a capturing one. 6lthough this is not defined in anspecifications %as far as I know(, and ou shouldn$t count on it for a program$s correctness, a non=

    capturing lambda onl needs to be evaluated once. -rom then on, it will return an identical instance.

    apturing lambdas need to be evaluated ever time the$re encountered, and currentl that performs

    much like instantiating a new instance of an anonmous class.

    Fhat lambdas don$t do

  • 8/9/2019 JDK 8 Features

    16/40

  • 8/9/2019 JDK 8 Features

    17/40

    demonstrate this workaround. 6dd factor methods to convert from a lambda to an instance/

    rderingAtringB order L rdering.from%%a, b( =B ...(H

    ache0oaderAtring, tringB loader L

    ache0oader.from%%ke( =B ...(H

    -or further reading, see this e)planation written b rian 3oetO/ response to E6llow lambdas to

    implement abstract classesE

    java.util.function

    2ackage summar/java.util.function

    6s demonstrated earlier with omparator and unnable, interfaces alread defined in the J&' that

    happen to be functional interfaces are compatible with lambdas.

  • 8/9/2019 JDK 8 Features

    18/40

    primitives.

    java.util.stream

    2ackage summar/java.util.stream

  • 8/9/2019 JDK 8 Features

    19/40

    method in the e)ample above is a terminal operation.

    ?suall, dealing with a stream will involve these steps/

    1. btain a stream from some source.

    !. 2erform one or more intermediate operations.

    #. 2erform one terminal operation.

    It$s likel that ou$ll want to perform all those steps within one method.

  • 8/9/2019 JDK 8 Features

    20/40

    tream.

    peek1= 2erform some action on each element as it is encountered. 2rimaril useful for

    debugging.

    distinct1= >)clude all duplicate elements according to their .eNuals behavior. nsure that stream elements in subseNuent operations are encountered according

    to the order imposed b a omparator. nsure that subseNuent operations onl see up to a ma)imum number of elements.nsure that subseNuent operations do not see the first n elements.

  • 8/9/2019 JDK 8 Features

    21/40

    2redicate.

  • 8/9/2019 JDK 8 Features

    22/40

    0ongtream

    &oubletream

    ne can convert back and forth between an object stream and a primitive stream using the

    primitive=specialiOed map and flat5ap functions, among others.

  • 8/9/2019 JDK 8 Features

    23/40

    ummar of proposal/ J>2 1"1/ 3eneraliOed

  • 8/9/2019 JDK 8 Features

    24/40

    &ate.toInstant%(

    &ate.from%Instant(

    alendar.toInstant==

  • 8/9/2019 JDK 8 Features

    25/40

  • 8/9/2019 JDK 8 Features

    26/40

    5ap.remove%bject, bject(

    5ap.replace%', 4, 4(

    5ap.replace%', 4(

    5ap.computeIf6bsent%', -unction(

    5ap.computeIf2resent%', i-unction(

    5ap.compute%', i-unction(

    5ap.merge%', 4, i-unction(

    5ap.getr&efault%bject, 4(

    6lso, Iterator.remove%(now has a default, throwing implementation, which makes it slightl easier

    to define unmodifiable iterators.

    ollection.stream%( and ollection.paralleltream%( are the main gatewas into the stream 62I.

  • 8/9/2019 JDK 8 Features

    27/40

    this was not possible.

    5ap.computeIf6bsent makes working with multimap=like structures easier/

    QQ Inde) strings b length/

    5apAInteger, 0istAtringBB map L new ash5apAB%(H

    for %tring s / strings( C map.computeIf6bsent%s.length%(,

    ke =B new 6rra0istAtringB%((

    .add%s(H

    QQ 6lthough in this case the stream 62I ma be a better choice/

    5apAInteger, 0istAtringBB map L strings.stream%( .collect%ollectors.grouping%tring//length((H

    oncurrenc 62I additions

    -orkJoin2ool.common2ool%(

    oncurrentash5ap%v8(

  • 8/9/2019 JDK 8 Features

    28/40

    ompletiontage

    tamped0ock

    0ong6dder

    0ong6ccumulator

    &ouble6dder

    &ouble6ccumulator

    ountedompleter

    >)ecutors.newForktealing2ool%(

    >)ecutors.newForktealing2ool%int(

    )ecutorerviceQ>)ecutor when ou needone.

    oncurrentash5apA', 4B was completel rewritten. Internall it looks nothing like the version

    that was in Java 7. >)ternall it$s mostl the same, e)cept it has a large number of bulk operation

    http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/StampedLock.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/LongAdder.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/LongAccumulator.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/DoubleAdder.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/DoubleAccumulator.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountedCompleter.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newWorkStealingPool--http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newWorkStealingPool-int-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#getAndUpdate-java.util.function.UnaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#updateAndGet-java.util.function.UnaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#getAndAccumulate-V-java.util.function.BinaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#accumulateAndGet-V-java.util.function.BinaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/StampedLock.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/LongAdder.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/LongAccumulator.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/DoubleAdder.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/DoubleAccumulator.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountedCompleter.htmlhttp://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newWorkStealingPool--http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newWorkStealingPool-int-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#getAndUpdate-java.util.function.UnaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#updateAndGet-java.util.function.UnaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#getAndAccumulate-V-java.util.function.BinaryOperator-http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html#accumulateAndGet-V-java.util.function.BinaryOperator-
  • 8/9/2019 JDK 8 Features

    29/40

    methods/ man forms of reduce, search, and for>ach.

    oncurrentash5ap.new'eet%( provides a concurrent java.util.et implementation. It is

    essentiall another wa of writing ollections.newet-rom5ap%new oncurrentash5apA

  • 8/9/2019 JDK 8 Features

    30/40

    unchecked e)ception.

    5ost of these additions give ou was to obtain java.util.stream.tream from files and

    Inputtreams. )ception. 6lso, the are instances of streams where using

    the stream.close%(method is necessar. treams implement6utoloseableand can therefore be

    used in tr=with=resources statements. treams also have an onlose%unnable(intermediate

    operation that I didn$t list in the earlier section about streams. It allows ou to attach handlers to astream that e)ecute when it is closed. ere is an e)ample/

    QQ 2rint the lines in a file, then EdoneE

    tr %tream lines L -iles.lines%path, ?ach%stem.out//println(H

    eflection and annotation changes

    tpe annotations %J #"8(

    6nnotated6rralement.get6nnotationslement.get&eclared6nnotation%lass(

    6nnotated>lement.get&eclared6nnotations

  • 8/9/2019 JDK 8 Features

    31/40

    lass.get6nnotatedInterfaces%(

    lass.get6nnotateduperclass%(

    lass.get)ecutable

    -ield.get6nnotated

  • 8/9/2019 JDK 8 Features

    32/40

    I did not e)periment with +ashorn so I know ver little beond what$s described in the proposal

    above. hort version/ It$s the successor to hino. hino is old and a little bit slow, and thedevelopers decided the$d be better off starting from scratch.

    ther miscellaneous additions to java.lang, java.util, and elsewhere

  • 8/9/2019 JDK 8 Features

    33/40

    ptional

    ptionalInt

    ptional0ong

    ptional&ouble

    ase*:

    tringJoiner

    pliterator

    pliterators

    omparator.naturalrder%(

    omparator.reverserder%(

    omparator.nulls-irst%omparator(

    omparator.nulls0ast%omparator(

    omparator.comparing%-unction, omparator(

    omparator.comparing%-unction(

    omparator.comparingInt%

  • 8/9/2019 JDK 8 Features

    34/40

    omparator.reversed%(

    omparator.thenomparing%omparator(

    omparator.thenomparing%-unction, omparator(

    omparator.thenomparing%-unction(

    omparator.thenomparingInt%

  • 8/9/2019 JDK 8 Features

    35/40

    5ath.add>)act%long, long(

    5ath.subtract>)act%int, int(

    5ath.subtract>)act%long, long(

    5ath.multipl>)act%int, int(

    5ath.multipl>)act%long, long(

    5ath.negate>)act%int(

    5ath.negate>)act%long(

    5ath.decrement>)act%int(

    5ath.decrement>)act%long(

    5ath.increment>)act%int(

    5ath.increment>)act%long(

    5ath.floor&iv%int, int(

    5ath.floor&iv%long, long(

    5ath.floor5od%int, int(

    5ath.floor5od%long, long(

    5ath.toInt>)act%long(

    5ath.ne)t&own%float(

    http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#addExact-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#subtractExact-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#subtractExact-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#multiplyExact-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#multiplyExact-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#negateExact-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#negateExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#decrementExact-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#decrementExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#incrementExact-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#incrementExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorDiv-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorDiv-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#toIntExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextDown-float-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#addExact-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#subtractExact-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#subtractExact-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#multiplyExact-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#multiplyExact-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#negateExact-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#negateExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#decrementExact-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#decrementExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#incrementExact-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#incrementExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorDiv-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorDiv-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#toIntExact-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextDown-float-
  • 8/9/2019 JDK 8 Features

    36/40

    5ath.ne)t&own%double(

    Integer.min%int, int(

    Integer.ma)%int, int(

    Integer.sum%int, int(

    0ong.min%long, long(

    0ong.ma)%long, long(

    0ong.sum%long, long(

    &ouble.min%double, double(

    &ouble.ma)%double, double(

    &ouble.sum%double, double(

    2rimitive.hashode%primitive( %one new static method on each of the primitive wrapper

    tpes(

    oolean.logical6nd%boolean, boolean(

    oolean.logicalr%boolean, boolean(

    oolean.logicalXor%boolean, boolean(

    Integer.to?nsigned0ong%int(

    Integer.to?nsignedtring%int(

    Integer.to?nsignedtring%int, int(

    http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextDown-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#min-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#max-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#sum-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#min-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#max-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#sum-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#min-double-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#max-double-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#sum-double-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#logicalAnd-boolean-boolean-http://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#logicalOr-boolean-boolean-http://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#logicalXor-boolean-boolean-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#toUnsignedLong-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#toUnsignedString-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#toUnsignedString-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextDown-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#min-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#max-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#sum-int-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#min-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#max-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#sum-long-long-http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#min-double-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#max-double-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#sum-double-double-http://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#logicalAnd-boolean-boolean-http://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#logicalOr-boolean-boolean-http://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#logicalXor-boolean-boolean-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#toUnsignedLong-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#toUnsignedString-int-http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#toUnsignedString-int-int-
  • 8/9/2019 JDK 8 Features

    37/40

    Integer.parse?nsignedInt%tring(

    Integer.parse?nsignedInt%tring, int(

    Integer.compare?nsigned%int, int(

    0ong.to?nsignedtring%long, int(

    0ong.to?nsignedtring%long(

    0ong.parse?nsigned0ong%tring, int(

    0ong.parse?nsigned0ong%tring(

    0ong.compare?nsigned%long, long(

    0ong.divide?nsigned%long, long(

    0ong.remainder?nsigned%long, long(

    igInteger.long4alue>)act%(

    igInteger.int4alue>)act%(

    igInteger.short4alue>)act%(

    igInteger.bte4alue>)act%(

    bjects.is+ull%bject(= useful as a predicate, e.g. stream.an5atch%bjects//is+ull(

    bjects.non+ull%bject(= useful as a predicate, e.g. stream.filter%bjects//non+ull(

    bjects.reNuire+on+ull%

  • 8/9/2019 JDK 8 Features

    38/40

    andom.ints%(

    andom.longs%(

    andom.doubles%(

    ecureandom.gettrongecureandom%(

    itet.stream%(

    Intummartatistics

    0ongummartatistics

    &oubleummartatistics

    2attern.split6stream%hareNuence(

    2attern.as2redicate%(

    2rocess.wait-or%long,

  • 8/9/2019 JDK 8 Features

    39/40

    5iscellaneous additions to 0ocale

    5iscellaneous additions to esultet

  • 8/9/2019 JDK 8 Features

    40/40

    b several orders of magnitude.E

    rian 3oetO in response to Eptional reNuire%s( +on+ullE

    tringJoiner and tring.join%...( are long, long overdue.