41

Java in the Past, Java in the Future

Embed Size (px)

Citation preview

Page 1: Java in the Past, Java in the Future
Page 2: Java in the Past, Java in the Future
Page 3: Java in the Past, Java in the Future
Page 4: Java in the Past, Java in the Future
Page 5: Java in the Past, Java in the Future
Page 6: Java in the Past, Java in the Future
Page 7: Java in the Past, Java in the Future
Page 8: Java in the Past, Java in the Future
Page 9: Java in the Past, Java in the Future
Page 10: Java in the Past, Java in the Future
Page 11: Java in the Past, Java in the Future
Page 12: Java in the Past, Java in the Future
Page 13: Java in the Past, Java in the Future
Page 14: Java in the Past, Java in the Future
Page 15: Java in the Past, Java in the Future
Page 16: Java in the Past, Java in the Future
Page 17: Java in the Past, Java in the Future
Page 18: Java in the Past, Java in the Future
Page 19: Java in the Past, Java in the Future
Page 20: Java in the Past, Java in the Future
Page 21: Java in the Past, Java in the Future
Page 22: Java in the Past, Java in the Future
Page 23: Java in the Past, Java in the Future
Page 24: Java in the Past, Java in the Future
Page 25: Java in the Past, Java in the Future

From External IterationTo Internal Iteration

List<Long> nums = ...;List<Long> nums2 = new ArrayList<>();

for (long n: nums) { nums2.add(n*2L);}

BeforeList<Long> nums = ...;

List<Long> nums2 = nums.stream() .map(new Function<Long,Long>(){ @Override public Long aply(Long n) { return n*2L; } }) .collect(Collectors.toList());

List<Long> nums = ...;

List<Long> nums2 = nums.stream() .map(new Function<Long,Long>(){ @Override public Long aply(Long n) { return n*2L; } }) .collect(Collectors.toList());

Boilerplate!

List<Long> nums = ...;

List<Long> nums2 = nums.stream() .map(

n -> n*2L ) .collect(Collectors.toList());

After

Page 26: Java in the Past, Java in the Future

From External IterationTo Internal Iteration

List<Long> nums = ...;

List<Long> nums2 = nums.stream() .map(new Function<Long,Long>(){ @Override public Long aply(Long n) { return n*2L; } }) .collect(Collectors.toList());

Page 27: Java in the Past, Java in the Future

From External IterationTo Internal Iteration

List<Long> nums = ...;

List<Long> nums2 = nums.stream() .map(new Function<Long,Long>(){ @Override public Long aply(Long n) { return n*2L; } }) .collect(Collectors.toList());

Boilerplate!

Page 28: Java in the Past, Java in the Future

From External IterationTo Internal Iteration

List<Long> nums = ...;

List<Long> nums2 = nums.stream() .map(

n -> n*2L ) .collect(Collectors.toList());

After

Page 29: Java in the Past, Java in the Future
Page 30: Java in the Past, Java in the Future
Page 31: Java in the Past, Java in the Future
Page 32: Java in the Past, Java in the Future
Page 33: Java in the Past, Java in the Future
Page 34: Java in the Past, Java in the Future
Page 35: Java in the Past, Java in the Future
Page 36: Java in the Past, Java in the Future
Page 37: Java in the Past, Java in the Future
Page 38: Java in the Past, Java in the Future
Page 39: Java in the Past, Java in the Future
Page 40: Java in the Past, Java in the Future
Page 41: Java in the Past, Java in the Future