Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
As Velhas Novas do Java 7
Carlos Alexandro Becker
June 05, 2014
Programming
0
31
As Velhas Novas do Java 7
Carlos Alexandro Becker
June 05, 2014
Tweet
Share
More Decks by Carlos Alexandro Becker
See All by Carlos Alexandro Becker
caarlos0
0
220
caarlos0
0
510
caarlos0
0
840
caarlos0
0
580
caarlos0
0
900
caarlos0
1
900
caarlos0
3
130
caarlos0
1
2.3k
caarlos0
1
92
Other Decks in Programming
See All in Programming
naokioouchi
1
300
manfredsteyer
PRO
0
160
layzee
1
220
prof18
0
1.5k
madai0517
1
200
kawaji_scratch
0
110
aftiopk
0
120
grapecity_dev
0
180
manfredsteyer
PRO
0
130
mihyaeru21
0
360
manfredsteyer
PRO
0
230
bkuhlmann
2
310
Featured
See All Featured
bkeepers
408
58k
shlominoach
176
7.5k
maltzj
502
36k
brettharned
93
3k
sugarenia
233
860k
chrislema
173
14k
reverentgeek
167
7.3k
tenderlove
53
3.5k
destraynor
222
47k
edds
56
9.4k
addyosmani
311
21k
keithpitt
401
20k
Transcript
Java 7 as velhas novas do
Java 6: Dec 2006 Java 7: Jul 2011 Java 8:
Mar 2014 História
Lambdas, Jigsaw, e parte do Project Coin foram dropados do
Java 7
Agenda • Diamond Operator • Strings em Switch’s • Automatic
Resource Management • Numeric Literals com Underscores • Exception Handling (multi-catch) • NIO 2.0 • Fork and Join • invokedynamic
Diamond Operator // java 6 Map<String, List<String>> list6 =
new TreeMap<String, List<String>>(); // java 7 Map<String, List<String>> list7 = new TreeMap<>();
String em Switch’s // java 6 AnEnum a = AnEnum.A;
switch (a) { case A: doSomethingWhenA(); break; // … }
String em Switch’s // java 7 String b = "b";
switch(b) { case "b": doSomethingWhenB(); break; // … }
Automatic Resource Management // java 6 BlahResource resource; try {
resource = new BlahResource(); resource.doSomething(); } catch (Exception e) { log.error( “Maoeee”, e ); } finally { try { resource.close(); } catch (BlahResourceException e) { log.error( “Ah haee”, e ); } }
Automatic Resource Management // java 7 try (BlahResource resource =
new BlahResource()) { resource.doSomething(); } catch (Exception e) { log.error( “Maoeee”, e ); }
Numeric Literals // java 6 int thousand = 1000; //
java 7 int thousand = 1_000;
Exception Handling // java 6 try { oneThousandCheckedExceptionsLater(); } catch
(ExceptionOne e) { log.error(“Erro: ", e); } catch (ExceptionTwo e) { log.error(“Erro: ", e); } catch (ExceptionThree e) { log.error(“Erro: ", e); }
Exception Handling // java 7 try { oneThousandCheckedExceptionsLater(); } catch
(ExceptionOne | ExceptionTwo | ExceptionThree e) { log.error(“Erro:”, e); }
NIO 2.0 • Path & Paths • Files • FileSystems
• WatchService
Fork and Join • Dividir para conquistar • ForkJoinTask &
ForkJoinPool
incokedynamic • Recurso da JVM para suportar melhor linguagens com
tipagem dinâmica • java.lang.invoke
PROTIPS™
None
GRÁTIS NA LOJA KINDLE!
Bom e velho Javadoc ☕️
Dúvidas?
Thanks https://speakerdeck.com/caarlos0/as-velhas-novas-do-java-7