Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Java 8 Collections
Featuring Hack-n-Slash!
Java
Collection
Model
Java
Collection
Model
Hack-n-Slash!
• CaptainOpcode
• lambda_@rity
• Sir-Fragsalot
• general_f@1lur3
• deep_web9
Challenge #1: Sorting
Challenge #1: Sorting
Challenge #1: Sorting
Java 7
Java 8
Challenge #2: Removal
Challenge #2: Removal
Java 7
Challenge #2: Removal
Java 7
Challenge #2: Removal
Java 7
Java 8
Score Map
PLAYER NAME SCORE
CAPTAINOPCODE 2500
LAMBDA_@RITY 450
SIR-FRAGSALOT 1475
GENERAL_F@1LUR3 825
DEEP_WEB9 250
Score Map Output
CaptainOpcode has a score of 2500
lambda_@rity has a score of 450
Sir-Fragsalot has a score of 1475
gener...
Challenge #3: Map Loop
Java 7
Java 8
Score Map
PLAYER NAME SCORE
CAPTAINOPCODE 2500
LAMBDA_@RITY 450
SIR-FRAGSALOT 1475
GENERAL_F@1LUR3 825
DEEP_WEB9 250
1650
Challenge #4: Compute
Java 7
Java 8
• Map.compute(key, remappingFunction)
• Map.computeIfAbsent(key, mappingFunction)
• Ma...
Score Map
PLAYER NAME SCORE
CAPTAINOPCODE 2500
LAMBDA_@RITY 450
SIR-FRAGSALOT 1475
GENERAL_F@1LUR3 1650
DEEP_WEB9 250
950
...
Challenge #5: Update
Java 7
Java 8
Honorable Mentions
• Map.getOrDefault(key, value)
• Map.putIfAbsent(key, value)
• Map.replace(key, value)
• Map.replace(ke...
Thank You
@djleeds
+DaveLeeds
HittheBits.com
©2014 Dave Leeds. Code samples are licensed under the MIT License.
Upcoming SlideShare
Loading in …5
×

Java 8 Collection API Updates

3,965 views

Published on

Demonstrates some of the updates to the collection interfaces in Java 8, including sort(), removeIf(), forEach(), compute(), and replaceAll().

  • Be the first to comment

Java 8 Collection API Updates

  1. 1. Java 8 Collections Featuring Hack-n-Slash!
  2. 2. Java Collection Model
  3. 3. Java Collection Model
  4. 4. Hack-n-Slash! • CaptainOpcode • lambda_@rity • Sir-Fragsalot • general_f@1lur3 • deep_web9
  5. 5. Challenge #1: Sorting
  6. 6. Challenge #1: Sorting
  7. 7. Challenge #1: Sorting Java 7 Java 8
  8. 8. Challenge #2: Removal
  9. 9. Challenge #2: Removal Java 7
  10. 10. Challenge #2: Removal Java 7
  11. 11. Challenge #2: Removal Java 7 Java 8
  12. 12. Score Map PLAYER NAME SCORE CAPTAINOPCODE 2500 LAMBDA_@RITY 450 SIR-FRAGSALOT 1475 GENERAL_F@1LUR3 825 DEEP_WEB9 250
  13. 13. Score Map Output CaptainOpcode has a score of 2500 lambda_@rity has a score of 450 Sir-Fragsalot has a score of 1475 general_f@1lur3 has a score of 825 deep_web9 has a score of 250
  14. 14. Challenge #3: Map Loop Java 7 Java 8
  15. 15. Score Map PLAYER NAME SCORE CAPTAINOPCODE 2500 LAMBDA_@RITY 450 SIR-FRAGSALOT 1475 GENERAL_F@1LUR3 825 DEEP_WEB9 250 1650
  16. 16. Challenge #4: Compute Java 7 Java 8 • Map.compute(key, remappingFunction) • Map.computeIfAbsent(key, mappingFunction) • Map.computeIfPresent(key, remappingFunction) put put put
  17. 17. Score Map PLAYER NAME SCORE CAPTAINOPCODE 2500 LAMBDA_@RITY 450 SIR-FRAGSALOT 1475 GENERAL_F@1LUR3 1650 DEEP_WEB9 250 950 750
  18. 18. Challenge #5: Update Java 7 Java 8
  19. 19. Honorable Mentions • Map.getOrDefault(key, value) • Map.putIfAbsent(key, value) • Map.replace(key, value) • Map.replace(key, value, value) • Map.remove(key, value)
  20. 20. Thank You @djleeds +DaveLeeds HittheBits.com ©2014 Dave Leeds. Code samples are licensed under the MIT License.

×