SlideShare a Scribd company logo
1 of 18
What's New in Java SE 8
A Quick Look at the Platform Enhancements
1
Objectives
When we are done, you should be able to use:
Functional interfaces
Default methods
Lambdas and lambda expressions
java.time package
2© DevelopIntelligence http://www.DevelopIntelligence.com
Functional Interfaces
Interface containing only one method
Can annotate with java.lang.FunctionalInterface
If only one method, the annotation is not needed
Primarily used as targets for lambdas
Several have been pre-defined in
java.util.function
Predicate – used for tests; takes an argument, compares it to
the given Predicate
Function – takes an argument, returns response
Consumer – takes an argument, returns nothing
3© DevelopIntelligence http://www.DevelopIntelligence.com
Default Methods
Specialized methods found in interfaces
Marked with default keyword
Allows us to add methods to an interface long after it has
been released without breaking the interface
4© DevelopIntelligence http://www.DevelopIntelligence.com
@FunctionalInterface
public interface Predicate<T> {
public boolean test();
default Predicate<T> and(Predicate<? super T> other){
//do stuff
}
}
Lambda Expressions
Mechanism to pass functionality as an argument
Way to simplify reading of code
Anonymous inner classes tend to be bulky
Multiple functionality options decrease DRY properties and/or
cause explosion in number of methods
5© DevelopIntelligence http://www.DevelopIntelligence.com
Example: Customer
public class Customer {
private String firstName, surName;
private String street, city, state, postalCode;
public Customer (String firstName, String surName,
String postalCode){
this.firstName = firstName;
this.surName = surName;
this.postalCode = postalCode;
}
<all appropriate accessor, mutators and constructors
written here>
6© DevelopIntelligence http://www.DevelopIntelligence.com
Example: MailingList
public List<Customer> findBySurName(String surName){
List<Customer> tempList = new ArrayList<>();
for(Customer c : customerList){
if(c.getSurName().equals(surName)){
tempList.add(c);
}
}
return tempList;
}
We would need something like this for every search method
7© DevelopIntelligence http://www.DevelopIntelligence.com
Writing Lambdas
Consists of three parts
Comma-separated list of parameters enclosed in parentheses
Arrow →
Body of expression
If one expression, it is evaluated and result is returned
If it is a block, return statement can be explicitly defined
Sometimes contains ::
Can only be used when the Java compiler can determine
the data type
Called “Target Type”
8© DevelopIntelligence http://www.DevelopIntelligence.com
Lambda Expression: Part 1
Called method replaces all the various options
public List<Customer> findCustomer
(Predicate<Customer> tester){
List<Customer> customer = new ArrayList<>();
for(Customer c: customerList) {
if(tester.test(c))
customer.add(c);
}
return customer;
}
9© DevelopIntelligence http://www.DevelopIntelligence.com
Lambda Expression: Part 2
Calling method has the lambda expression
modifiedList = ml.findCustomer(c->
c.getSurName().equals("Smith") &&
c.getPostalCode().equals("12346"));
for(Customer c: modifiedList){
System.out.printf("Customer List: %s, %sn",
c.getSurName(), c.getFirstName());
});
10© DevelopIntelligence http://www.DevelopIntelligence.com
Charset Improvements
Goal
Decrease size of installed charsets
Reduce maintenance cost
Improve performance of encoding/decoding
Improved performance of String(byte[], …) and
string.getBytes()
11© DevelopIntelligence http://www.DevelopIntelligence.com
New Date-Time Package
java.time package is the base
Divided into two types
• Human – based on days, months, hours
• Machine (or continuous) – based on Unix Time
Immutable and thus thread safe
Methods perform same action in each class
Works with ISO-8601 calendar system and non-ISO calendar
systems
Designed to be more natural to use and less clumsy than
Calendar
12© DevelopIntelligence http://www.DevelopIntelligence.com
Date-Time Example
13© DevelopIntelligence http://www.DevelopIntelligence.com
import java.time.*;
public class DateTime {
public static void main(String[] args) {
LocalTime local = LocalTime.now();
System.out.println("The time is now " + local);
LocalTime hours = local.plusHours(5);
System.out.println("In 5 hours is will be " + hours);
int seconds = local.toSecondOfDay();
System.out.println("The total number of seconds for
today is " + seconds);
}
}
Date-Time Example (cont.)
The previous example has the following results:
The time is now 20:07:43.289
In 5 hours it will be 01:07:43.289
The total number of seconds since midnight is 72463
14© DevelopIntelligence http://www.DevelopIntelligence.com
java.time Package
Has two enums
DayOfWeek
Month
Continuous classes
Instant
Duration
All others are considered 'human'
15© DevelopIntelligence http://www.DevelopIntelligence.com
SelectorProvider
Abstract class whose subclasses give us access to the
various channel streams
Now have one specific to Solaris using its event port mechanism
-Djava.nio.channels.spi.SelectorProvider=
sun.nio.ch.EventPortSelectorProvider
16© DevelopIntelligence http://www.DevelopIntelligence.com
Closing
Thank you!

DevelopIntelligence
http://www.Develop
Intelligence.com
Contact
Does your team need to build its Java skills and knowledge beyond today's
webinar’s offerings? We have some of the best Java instructors in the industry.
Contact us today to discuss available learning solutions.
Develop Intelligence
(877) 629-5631
info@developintelligence.com
Twitter: @DevIntelligence
Stay in the know about developer news, tools, SDKs, technical presentations,
events and future webinars, connect with AMD Central here:
AMD Developer Central
Twitter: @AMDDevCentral
Web: http://developer.amd.com/
Developer Forums: devgurus.amd.com/welcome

More Related Content

What's hot

What's hot (20)

GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin CoumansGS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
 
MM-4097, OpenCV-CL, by Harris Gasparakis, Vadim Pisarevsky and Andrey Pavlenko
MM-4097, OpenCV-CL, by Harris Gasparakis, Vadim Pisarevsky and Andrey PavlenkoMM-4097, OpenCV-CL, by Harris Gasparakis, Vadim Pisarevsky and Andrey Pavlenko
MM-4097, OpenCV-CL, by Harris Gasparakis, Vadim Pisarevsky and Andrey Pavlenko
 
PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...
PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...
PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...
 
CC-4001, Aparapi and HSA: Easing the developer path to APU/GPU accelerated Ja...
CC-4001, Aparapi and HSA: Easing the developer path to APU/GPU accelerated Ja...CC-4001, Aparapi and HSA: Easing the developer path to APU/GPU accelerated Ja...
CC-4001, Aparapi and HSA: Easing the developer path to APU/GPU accelerated Ja...
 
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor MillerPL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
 
LCU13: GPGPU on ARM Experience Report
LCU13: GPGPU on ARM Experience ReportLCU13: GPGPU on ARM Experience Report
LCU13: GPGPU on ARM Experience Report
 
MM-4105, Realtime 4K HDR Decoding with GPU ACES, by Gary Demos
MM-4105, Realtime 4K HDR Decoding with GPU ACES, by Gary DemosMM-4105, Realtime 4K HDR Decoding with GPU ACES, by Gary Demos
MM-4105, Realtime 4K HDR Decoding with GPU ACES, by Gary Demos
 
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla MahGS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
 
Direct3D12 and the Future of Graphics APIs by Dave Oldcorn
Direct3D12 and the Future of Graphics APIs by Dave OldcornDirect3D12 and the Future of Graphics APIs by Dave Oldcorn
Direct3D12 and the Future of Graphics APIs by Dave Oldcorn
 
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
 
PT-4142, Porting and Optimizing OpenMP applications to APU using CAPS tools, ...
PT-4142, Porting and Optimizing OpenMP applications to APU using CAPS tools, ...PT-4142, Porting and Optimizing OpenMP applications to APU using CAPS tools, ...
PT-4142, Porting and Optimizing OpenMP applications to APU using CAPS tools, ...
 
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
 
Introduction to OpenCL
Introduction to OpenCLIntroduction to OpenCL
Introduction to OpenCL
 
PostgreSQL with OpenCL
PostgreSQL with OpenCLPostgreSQL with OpenCL
PostgreSQL with OpenCL
 
Gcn performance ftw by stephan hodes
Gcn performance ftw by stephan hodesGcn performance ftw by stephan hodes
Gcn performance ftw by stephan hodes
 
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
 
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
 
PT-4058, Measuring and Optimizing Performance of Cluster and Private Cloud Ap...
PT-4058, Measuring and Optimizing Performance of Cluster and Private Cloud Ap...PT-4058, Measuring and Optimizing Performance of Cluster and Private Cloud Ap...
PT-4058, Measuring and Optimizing Performance of Cluster and Private Cloud Ap...
 
WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang...
WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang...WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang...
WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang...
 
Deeper Look Into HSAIL And It's Runtime
Deeper Look Into HSAIL And It's Runtime Deeper Look Into HSAIL And It's Runtime
Deeper Look Into HSAIL And It's Runtime
 

Viewers also liked

Rendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnellRendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
AMD Developer Central
 

Viewers also liked (16)

The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
 
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
 
Inside XBox- One, by Martin Fuller
Inside XBox- One, by Martin FullerInside XBox- One, by Martin Fuller
Inside XBox- One, by Martin Fuller
 
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnellRendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
 
TressFX The Fast and The Furry by Nicolas Thibieroz
TressFX The Fast and The Furry by Nicolas ThibierozTressFX The Fast and The Furry by Nicolas Thibieroz
TressFX The Fast and The Furry by Nicolas Thibieroz
 
DirectGMA on AMD’S FirePro™ GPUS
DirectGMA on AMD’S  FirePro™ GPUSDirectGMA on AMD’S  FirePro™ GPUS
DirectGMA on AMD’S FirePro™ GPUS
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Computer Vision Powered by Heterogeneous System Architecture (HSA) by Dr. Ha...
Computer Vision Powered by Heterogeneous System Architecture (HSA) by  Dr. Ha...Computer Vision Powered by Heterogeneous System Architecture (HSA) by  Dr. Ha...
Computer Vision Powered by Heterogeneous System Architecture (HSA) by Dr. Ha...
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
 
Media SDK Webinar 2014
Media SDK Webinar 2014Media SDK Webinar 2014
Media SDK Webinar 2014
 
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth ThomasHoly smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
 
Introduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan NevraevIntroduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan Nevraev
 
DX12 & Vulkan: Dawn of a New Generation of Graphics APIs
DX12 & Vulkan: Dawn of a New Generation of Graphics APIsDX12 & Vulkan: Dawn of a New Generation of Graphics APIs
DX12 & Vulkan: Dawn of a New Generation of Graphics APIs
 
Inside XBOX ONE by Martin Fuller
Inside XBOX ONE by Martin FullerInside XBOX ONE by Martin Fuller
Inside XBOX ONE by Martin Fuller
 
AMD and the new “Zen” High Performance x86 Core at Hot Chips 28
AMD and the new “Zen” High Performance x86 Core at Hot Chips 28AMD and the new “Zen” High Performance x86 Core at Hot Chips 28
AMD and the new “Zen” High Performance x86 Core at Hot Chips 28
 

Similar to Webinar: Whats New in Java 8 with Develop Intelligence

Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
Troy Miles
 

Similar to Webinar: Whats New in Java 8 with Develop Intelligence (20)

Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
JAVA_BASICS.ppt
JAVA_BASICS.pptJAVA_BASICS.ppt
JAVA_BASICS.ppt
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
Design for Testability
Design for TestabilityDesign for Testability
Design for Testability
 
Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
 
Performance Testing REST APIs
Performance Testing REST APIsPerformance Testing REST APIs
Performance Testing REST APIs
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 

More from AMD Developer Central

More from AMD Developer Central (9)

RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
 
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
 
Mantle - Introducing a new API for Graphics - AMD at GDC14
Mantle - Introducing a new API for Graphics - AMD at GDC14Mantle - Introducing a new API for Graphics - AMD at GDC14
Mantle - Introducing a new API for Graphics - AMD at GDC14
 
Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
 
Keynote (Tony King-Smith) - Silicon? Check. HSA? Check. All done? Wrong! - by...
Keynote (Tony King-Smith) - Silicon? Check. HSA? Check. All done? Wrong! - by...Keynote (Tony King-Smith) - Silicon? Check. HSA? Check. All done? Wrong! - by...
Keynote (Tony King-Smith) - Silicon? Check. HSA? Check. All done? Wrong! - by...
 
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
 
Keynote (Dr. Lisa Su) - Developers: The Heart of AMD Innovation - by Dr. Lisa...
Keynote (Dr. Lisa Su) - Developers: The Heart of AMD Innovation - by Dr. Lisa...Keynote (Dr. Lisa Su) - Developers: The Heart of AMD Innovation - by Dr. Lisa...
Keynote (Dr. Lisa Su) - Developers: The Heart of AMD Innovation - by Dr. Lisa...
 
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Webinar: Whats New in Java 8 with Develop Intelligence

  • 1. What's New in Java SE 8 A Quick Look at the Platform Enhancements 1
  • 2. Objectives When we are done, you should be able to use: Functional interfaces Default methods Lambdas and lambda expressions java.time package 2© DevelopIntelligence http://www.DevelopIntelligence.com
  • 3. Functional Interfaces Interface containing only one method Can annotate with java.lang.FunctionalInterface If only one method, the annotation is not needed Primarily used as targets for lambdas Several have been pre-defined in java.util.function Predicate – used for tests; takes an argument, compares it to the given Predicate Function – takes an argument, returns response Consumer – takes an argument, returns nothing 3© DevelopIntelligence http://www.DevelopIntelligence.com
  • 4. Default Methods Specialized methods found in interfaces Marked with default keyword Allows us to add methods to an interface long after it has been released without breaking the interface 4© DevelopIntelligence http://www.DevelopIntelligence.com @FunctionalInterface public interface Predicate<T> { public boolean test(); default Predicate<T> and(Predicate<? super T> other){ //do stuff } }
  • 5. Lambda Expressions Mechanism to pass functionality as an argument Way to simplify reading of code Anonymous inner classes tend to be bulky Multiple functionality options decrease DRY properties and/or cause explosion in number of methods 5© DevelopIntelligence http://www.DevelopIntelligence.com
  • 6. Example: Customer public class Customer { private String firstName, surName; private String street, city, state, postalCode; public Customer (String firstName, String surName, String postalCode){ this.firstName = firstName; this.surName = surName; this.postalCode = postalCode; } <all appropriate accessor, mutators and constructors written here> 6© DevelopIntelligence http://www.DevelopIntelligence.com
  • 7. Example: MailingList public List<Customer> findBySurName(String surName){ List<Customer> tempList = new ArrayList<>(); for(Customer c : customerList){ if(c.getSurName().equals(surName)){ tempList.add(c); } } return tempList; } We would need something like this for every search method 7© DevelopIntelligence http://www.DevelopIntelligence.com
  • 8. Writing Lambdas Consists of three parts Comma-separated list of parameters enclosed in parentheses Arrow → Body of expression If one expression, it is evaluated and result is returned If it is a block, return statement can be explicitly defined Sometimes contains :: Can only be used when the Java compiler can determine the data type Called “Target Type” 8© DevelopIntelligence http://www.DevelopIntelligence.com
  • 9. Lambda Expression: Part 1 Called method replaces all the various options public List<Customer> findCustomer (Predicate<Customer> tester){ List<Customer> customer = new ArrayList<>(); for(Customer c: customerList) { if(tester.test(c)) customer.add(c); } return customer; } 9© DevelopIntelligence http://www.DevelopIntelligence.com
  • 10. Lambda Expression: Part 2 Calling method has the lambda expression modifiedList = ml.findCustomer(c-> c.getSurName().equals("Smith") && c.getPostalCode().equals("12346")); for(Customer c: modifiedList){ System.out.printf("Customer List: %s, %sn", c.getSurName(), c.getFirstName()); }); 10© DevelopIntelligence http://www.DevelopIntelligence.com
  • 11. Charset Improvements Goal Decrease size of installed charsets Reduce maintenance cost Improve performance of encoding/decoding Improved performance of String(byte[], …) and string.getBytes() 11© DevelopIntelligence http://www.DevelopIntelligence.com
  • 12. New Date-Time Package java.time package is the base Divided into two types • Human – based on days, months, hours • Machine (or continuous) – based on Unix Time Immutable and thus thread safe Methods perform same action in each class Works with ISO-8601 calendar system and non-ISO calendar systems Designed to be more natural to use and less clumsy than Calendar 12© DevelopIntelligence http://www.DevelopIntelligence.com
  • 13. Date-Time Example 13© DevelopIntelligence http://www.DevelopIntelligence.com import java.time.*; public class DateTime { public static void main(String[] args) { LocalTime local = LocalTime.now(); System.out.println("The time is now " + local); LocalTime hours = local.plusHours(5); System.out.println("In 5 hours is will be " + hours); int seconds = local.toSecondOfDay(); System.out.println("The total number of seconds for today is " + seconds); } }
  • 14. Date-Time Example (cont.) The previous example has the following results: The time is now 20:07:43.289 In 5 hours it will be 01:07:43.289 The total number of seconds since midnight is 72463 14© DevelopIntelligence http://www.DevelopIntelligence.com
  • 15. java.time Package Has two enums DayOfWeek Month Continuous classes Instant Duration All others are considered 'human' 15© DevelopIntelligence http://www.DevelopIntelligence.com
  • 16. SelectorProvider Abstract class whose subclasses give us access to the various channel streams Now have one specific to Solaris using its event port mechanism -Djava.nio.channels.spi.SelectorProvider= sun.nio.ch.EventPortSelectorProvider 16© DevelopIntelligence http://www.DevelopIntelligence.com
  • 18. Contact Does your team need to build its Java skills and knowledge beyond today's webinar’s offerings? We have some of the best Java instructors in the industry. Contact us today to discuss available learning solutions. Develop Intelligence (877) 629-5631 info@developintelligence.com Twitter: @DevIntelligence Stay in the know about developer news, tools, SDKs, technical presentations, events and future webinars, connect with AMD Central here: AMD Developer Central Twitter: @AMDDevCentral Web: http://developer.amd.com/ Developer Forums: devgurus.amd.com/welcome