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

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

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

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

Naoki Kishida

October 08, 2019
Tweet

More Decks by Naoki Kishida

Other Decks in Programming

Transcript

  1.  • ) 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
  2. ( ( )( • " #$ •   

         • #$ !  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"
  3. 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);
  4. 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 + ""; }
  5.      • ( 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"
  6. ) ( • [ 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
  7. 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)
  8. 3 6 3 6 ) ( ( ) ) 3

    63 • • 9
  9. ) 8 (: 6 3 )8 3 6 :8 2

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

    ) ( ( record Leaf(int val) {} var l = new Leaf(3); System.out.println(l.val()); System.out.println(l); 3 Leaf[val=3]
  11. ( ) 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 {}
  12. )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; } }
  13. ( ) 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; }