Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Java13が出たけどぱっとしないのでJava14を予想する / Java13 new feature and Java14 expectation

Java13が出たけどぱっとしないのでJava14を予想する / Java13 new feature and Java14 expectation

2019/10/8に開催されたJavaコミュ@福岡 勉強会1910での登壇資料です

9e840766611f942c7c0a9ad6987a5d78?s=128

Naoki Kishida

October 08, 2019
Tweet

More Decks by Naoki Kishida

Other Decks in Programming

Transcript

  1. +BWB͕ग़͚ͨͲ ͺͬͱ͠ͳ͍ͷͰ +BWBΛ༧૝͢Δ +BWBίϛϡˏ෱Ԭ ษڧձ  -*/&'VLVPLB͖ͩ͠ ͳ͓͖

  2. • // • 0 1 2

  3.  • ) C G D • 5 ) 4

    A E 4 D AC • 1 B E E : A E 0 • E IBC DD A D 0C G • 3 IE ( A D 0C G
  4. ( ( )( • " #$ •   

         • #$ !  jshell> s = """ ...> test ...> test ...> """ s ==> "test¥ntest¥n" jshell> s = """ ...> test ...> test ...> """ s ==> " test¥n test¥n" jshell> s = """ ...> test ...> test ...> """ s ==> "test¥n test¥n" jshell> s = """ ...> test ...> test ...> """ s ==> " test¥n test¥n"
  5. 3 ( 4 ) ) )3 •   

    •   IntStream.rangeClosed(1, 20) .mapToObj(i -> switch(i % 15) { case 3, 6, 9, 12 -> "Fizz"; case 5,10 -> "Buzz"; case 0 -> "FizzBuzz"; default -> i + ""; }) .map(FizzBuzz::makeStr) .forEach(System.out::print);
  6. 3 ( 4 ) ) )3 • 1 2 var

    result = switch (i % 15) { case 3, 6, 9, 12: yield "Fizz"; case 5, 10: yield "Buzz"; case 0: yield "FizzBuzz"; default: yield i + ""; }
  7. 3 5 •

  8. 1 3 • 26 G J • J 6 •

    1 E CB P
  9. 0 •     • !  

  10.  • . • . . . • . .

    • • E A
  11.      • ( D B •

    ) ( var s = """ select * from %1$s join %2$s on %1$s_id=%2$s_id """.formatted("product", "category"); "from product join category on product_id=category_id"
  12. ) ( • [ V • 5 I : G

    NEGA 4 A SNA BBA M • 2AG B G 5 GG6 EINA 0R A NE IM • V ] • ( 7AH PA N A I AIN 4 8 AA 48 1 CA GGA N • 6 CEIC 9 G AR A EHAIN G • ( 8 EN 0R AMME IM 8N I • ( 9ARN G M 8N I • 7A M 6 APEA • ( 8A GA 9S AM 6 APEA • T • 6 NNA I 4 N EIC B EIMN I A B 6 APEA • )( 6 NNA I H N EIC B M EN 6 APEA • :A N -63 3I N
  13. - 3 - 53 2 •    

     
  14. 3 •    jshell> String s = null

    s ==> null jshell> s.length() | java.lang.NullPointerException | at (#7:1) jshell> String s = null s ==> null jshell> s.length() | java.lang.NullPointerException | Cannot invoke method ‘length’ because ‘s’ is null | at (#7:1)
  15. 3 6 3 6 ) ( ( ) ) 3

    63 • • 9
  16. 3 • M M KR • 1 D K 3

    aJ •
  17. ) 8 (: 6 3 )8 3 6 :8 2

    1 )8 3 6 •     •   
  18. ) ( ) ) • ) C • • •

    ) ( ( record Leaf(int val) {} var l = new Leaf(3); System.out.println(l.val()); System.out.println(l); 3 Leaf[val=3]
  19. ( ) 0 • ( * $) &- • 2:

    ( * $,. /63980  • 14%! +'#"+/639 ( * $ 5<;7  sealed interface Node permits Branch, Leaf {} record Branch(Node left, Node right) implements Node {} record Leaf(Integer val) implements Node {}
  20. )0 ( 0 () 0)3 ) •   

      static int sum(Node n) { if (n instanceof Branch b) { return sum(b.left()) + sum(b.right()); } else if (n instanceof Leaf l) { return l.val(); } else { return 0; } }
  21. ( ) 66 2 1 6 02 3 806 )

    70 8 • E • J static int sum(Node n) { return switch (n) { case Branch b -> sum(b.left()) + sum(b.right()); case Leaf l -> l.val(); } } return switch(n) { case Branch(var l, var r) -> sum(l) + sum(r); case Leaf(var v) -> v; }
  22. )( •  !  •   

  23.  •