SlideShare a Scribd company logo
Java 7
New Features & Code Examples
Naresh Chintalcheru
Numeric Literals with Underscores

int thousand = 1_000;
int million = 1_000_000; //1000000 (one million)
double d1 = 1000_000_.0d
long a1 = 0b1000_1010_0010_1101_1010_0001_0100_0101L;

Imagine counting tens of zero’s ?. No need to strain
eyes or manual errors with Underscores
Bracket Notation for Collection
Old-Way
Collection<String> c = new ArrayList();
c.add(“one”);
c.add(“two”);
c.add(“ten”);
New-Way
Collection<String> c = new ArrayList {“one”, “two”, “ten”};
try-with-resource
Old-Way
BufferedReader br = null;

try {
br = new BufferedReader(new FileReader(path));
return br.readLine();
}catch(IOException ioEx) {}

finally {
try{
br.close();
}catch(IOException ioEx) {}
}
try-with-resource
• The File, JDBC, MQ, LDAP & Mail resource
connections will be opened & closed
• The finally block is used to make sure the
resources are closed
• Have another try-catch for closing the
resources
try-with-resource
New-Way
try (BufferedReader br = new BufferedReader(new FileReader(path));
BufferedWriter bw = new BufferedWriter(new FileWriter(path));

){
//File code
} catch(IOException ioEx) { }

With Java7 try-with-resource the resources
BufferedReader & BufferedWriter implements java.lang.
AutoCloseable and will be closed automatically
try-with-resource
New-Way
try (Statement stmt = con.createStatement()) {
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
String coffeeName = rs.getString("Name”);

} catch (SQLException e) { }

With Java7 try-with-resource the resource javax.sql.
Statement implements java.lang.AutoCloseable and will
be closed automatically
Multi-Catch
Old-Way
try {
//statements
} catch (ExceptionOne ex) {
logger.error(ex);
throw ex;
} catch (ExceptionTwo ex) {
logger.error(ex);
throw ex;
} catch (ExceptionThree ex) {
logger.error(ex);
throw ex;
}
Multi-Catch
New-Way
try {
//statements
} catch (ExceptionOne | ExceptionTwo | ExceptionThree ex) {
logger.error(ex);
throw ex;
}

Clean code with multiple exceptions in one Catch
block
Final Rethrow
void process() throws IOException, SQLException
try {
//statements
} catch (final
throw ex;
}

Throwable ex) {

New precise rethrow feature which lets catch and
throw the base exception while still throwing the
precise exception from the calling method
String in Switch Statement
Finally ☺ ☺ ☺
String day;

switch (day) {
case "Monday":
break;
case "Tuesday":
case "Sunday":
typeOfDay = "Weekend";
break;
default:
throw new IllegalArgumentException("Invalid");
}

.
Simple Generic Instance
Old-Way
List<String> strings = new ArrayList<String>();
Map<String, List<String>> myMap = new HashMap<String, List<String>>();

New-Way (Simple)
List<String> strings = new ArrayList<>();
Map<String, List<String>> myMap = new HashMap<>();

.
Java.nio.file* (NIO2)
java.nio.file.Files
java.nio.file.Path
java.nio.file.Paths
Paths and Path - File locations/names
Files - Operations on file content
FileSystem – provides file services
File.toPath() method, Lets older code interact with
the new java.nio API
.
Create File Symbolic Link
java.nio.file.Files.createSymbolicLink()
createSymbolicLink() – creates a symbolic link, if
supported by the file system
public static Path createSymbolicLink(Path link, Path
target, FileAttribute<?>... attrs) throws IOException
.
Path, Files & Scanner
final static Charset ENCODING = StandardCharsets.UTF_8;
List<String> readFile(String aFileName) throws IOException {
Path path = Paths.get(aFileName);
return Files.readAllLines(path, ENCODING); //Read List
}
void readFile(String aFileName) throws IOException {
Path path = Paths.get(aFileName);
try (Scanner scanner = new Scanner(path, ENCODING.name())){
while (scanner.hasNextLine()){
log(scanner.nextLine());
//Read String Line
}
}}

.
Path & Files To Write
final static Charset ENCODING = StandardCharsets.UTF_8;

void writeFile(List<String> aLines, String aFileName) throws IOException {
Path path = Paths.get(aFileName);
Files.write(path, aLines, ENCODING); //Write using List
}
void writeFile(String aFileName, List<String> aLines) throws IOException {
Path path = Paths.get(aFileName);
try (BufferedWriter writer = Files.newBufferedWriter(path, ENCODING)){
for(String line : aLines){
writer.write(line);
//Write String line
writer.newLine();
}
}}.
File Change Notifications
File Change Notifications with WatchService APIs
private void watch() {
Path path = Paths.get("C:Temptemp");
try {
watchService = FileSystems.getDefault().newWatchService();
path.register(watchService, ENTRY_CREATE, ENTRY_DELETE,
} catch (IOException e) {
System.out.println("IOException"+ e.getMessage());
}
}

ENTRY_MODIFY);
Streaming & Channel-based I/O
• A stream is a contiguous sequence of data. Stream IO acts on
a single character at a time, while channel IO works with a
buffer for each operation.
• These are supported by the Files class and Buffered IO is
usually more efficient to be used in reading and writing data.
• The java.nio.channels package's ByteChannel interface is a
channel that can read and write bytes.
• The SeekableByteChannel interface extends the ByteChannel
interface to maintain a position within the channel. The
position can be changed using seek type random IO
operations.
Asynchronous Channel-based I/O
Support for Asynchronous channel-based I/O functionality
• AsynchronousFileChannel class is used for file manipulation
operations that need to be performed in an asynchronous manner,
the methods supporting the File write and read operations.
• AsynchronousChannelGroup class provides a means of grouping
asynchronous channels together in order to share resources.
• Java.nio.file package's SecureDirectoryStream class provides
support for more secure access to directories. However, the
underlying operating system must provide local support for this class.
URLClassLoader Closing

The URLClassLoader.close() method eliminates the
problem of supporting updated implementations of the
classes and resources loaded from a particular
codebase, and in particular from JAR files.
URLClassLoader Closing
URL url = new URL("file:foo.jar");
URLClassLoader loader = new URLClassLoader (new URL[] {url});
Class cl = Class.forName ("Foo", true, loader);
Runnable foo = (Runnable) cl.newInstance();
foo.run();
loader.close ();
// foo.jar gets updated somehow
loader = new URLClassLoader (new URL[] {url});
cl = Class.forName ("Foo", true, loader);
foo = (Runnable) cl.newInstance();
// run the new implementation of Foo
foo.run();

Eliminates Server restarts
JDBCRowSet
The RowSetFactory interface and the RowSetProvider class, which enable you to create
all types of row sets supported by the JDBC driver.
RowSetFactory myRowSetFactory = RowSetProvider.newFactory();
JdbcRowSet jdbcRs = myRowSetFactory.createJdbcRowSet();
jdbcRs.setUrl("jdbc:driver:myAttribute");
jdbcRs.setUsername(username);
jdbcRs.setPassword(password);
jdbcRs.setCommand("select * from Emp");
jdbcRs.execute();
jdbcRs.moveToInsertRow();
jdbcRs.updateInt(“AGE", 0);
jdbcRs.insertRow();
jdbcRs.last();
jdbcRs.deleteRow();
Varargs
public class VarArgsJavav6 {
public static void main(String[] args) {
vaMethod("a", "b", "c");
}
public void vaMethod(String... args) {
for(String s : args)
System.out.println(s);
}
}
Automatically treats Method parameter as an Array
JVM G1 Garbage Collector
• The Garbage-First (G1) garbage collector achieves high
performance and pause time goals through several
techniques
• The G1 collector is a server-style garbage collector,
targeted for multi-processor machines with large
memories
• Meets garbage collection (GC) pause time goals with
high probability, while achieving high throughput.
Dynamic Language Support
• Java is a static typed language to make it little bit more
dynamic (long way to go) similar to dynamic typed languages
like Ruby, Python & Clojure the new package java.lang.
invoke is introduced
• A new package java.lang.invoke includes classes
MethodHandle, CallSite and others, has been created to
extend the support of dynamic languages

.
Java 7 Performance
Improved String Performance
Improved Array Performance
Security Enhancements
Support for Non-Java Languages - invokedynamic
References
http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html
http://radar.oreilly.com/2011/09/java7-features.html
http://www.slideshare.net/boulderjug/55-things-in-java-7
http://jaxenter.com/java-7-the-top-8-features-37156.html
http://stackoverflow.com/questions/2606620/what-are-the-new-features-in-java-7
http://tamanmohamed.blogspot.com/2012/06/jdk7-part-1-java-7-dolphin-newfeatures.html
http://tech.puredanger.com/java7/
Thank You

More Related Content

What's hot

Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
Stuart Roebuck
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
Ganesh Samarthyam
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
Sunghyouk Bae
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
Ganesh Samarthyam
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
Ganesh Samarthyam
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
Stuart Roebuck
 
Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8
Ganesh Samarthyam
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Ganesh Samarthyam
 
Hibernate
Hibernate Hibernate
Hibernate
Sunil OS
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
Iram Ramrajkar
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
Ecommerce Solution Provider SysIQ
 
Lambda Functions in Java 8
Lambda Functions in Java 8Lambda Functions in Java 8
Lambda Functions in Java 8
Ganesh Samarthyam
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
CodeOps Technologies LLP
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
Jim Bethancourt
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述fangjiafu
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
John Stevenson
 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
John David Duncan
 
Java Programming - 06 java file io
Java Programming - 06 java file ioJava Programming - 06 java file io
Java Programming - 06 java file io
Danairat Thanabodithammachari
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
Rafael Winterhalter
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
Geertjan Wielenga
 

What's hot (20)

Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
Hibernate
Hibernate Hibernate
Hibernate
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Lambda Functions in Java 8
Lambda Functions in Java 8Lambda Functions in Java 8
Lambda Functions in Java 8
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
 
Java Programming - 06 java file io
Java Programming - 06 java file ioJava Programming - 06 java file io
Java Programming - 06 java file io
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 

Viewers also liked

Asynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/SpringAsynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/Spring
Naresh Chintalcheru
 
Big Trends in Big Data
Big Trends in Big DataBig Trends in Big Data
Big Trends in Big Data
Naresh Chintalcheru
 
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Naresh Chintalcheru
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
Markus Eisele
 
3rd Generation Web Application Platforms
3rd Generation Web Application Platforms3rd Generation Web Application Platforms
3rd Generation Web Application Platforms
Naresh Chintalcheru
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
Naresh Chintalcheru
 
Spring 4 en spring data
Spring 4 en spring dataSpring 4 en spring data
Spring 4 en spring data
Geert Pante
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Edward Burns
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoC
Funnelll
 
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...ZeroTurnaround
 
Spring bean mod02
Spring bean mod02Spring bean mod02
Spring bean mod02Guo Albert
 
Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"
Michael Harlaut
 
Mule ESB Fundamentals
Mule ESB FundamentalsMule ESB Fundamentals
Mule ESB Fundamentals
Naresh Chintalcheru
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservices
Alvaro Sanchez-Mariscal
 
Dockercon State of the Art in Microservices
Dockercon State of the Art in MicroservicesDockercon State of the Art in Microservices
Dockercon State of the Art in Microservices
Adrian Cockcroft
 
Backday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratiqueBackday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratique
Publicis Sapient Engineering
 
Git Tours JUG 2010
Git Tours JUG 2010Git Tours JUG 2010
Git Tours JUG 2010David Gageot
 

Viewers also liked (19)

Asynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/SpringAsynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/Spring
 
Big Trends in Big Data
Big Trends in Big DataBig Trends in Big Data
Big Trends in Big Data
 
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
 
3rd Generation Web Application Platforms
3rd Generation Web Application Platforms3rd Generation Web Application Platforms
3rd Generation Web Application Platforms
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
 
Spring 4 en spring data
Spring 4 en spring dataSpring 4 en spring data
Spring 4 en spring data
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoC
 
Get ready for spring 4
Get ready for spring 4Get ready for spring 4
Get ready for spring 4
 
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
 
Spring bean mod02
Spring bean mod02Spring bean mod02
Spring bean mod02
 
Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"Webinar "Alfresco en une heure"
Webinar "Alfresco en une heure"
 
Mule ESB Fundamentals
Mule ESB FundamentalsMule ESB Fundamentals
Mule ESB Fundamentals
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservices
 
Dockercon State of the Art in Microservices
Dockercon State of the Art in MicroservicesDockercon State of the Art in Microservices
Dockercon State of the Art in Microservices
 
Backday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratiqueBackday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratique
 
Git Tours JUG 2010
Git Tours JUG 2010Git Tours JUG 2010
Git Tours JUG 2010
 

Similar to Java7 New Features and Code Examples

Java
JavaJava
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
Scott Leberknight
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
caswenson
 
Lambda functions in java 8
Lambda functions in java 8Lambda functions in java 8
Lambda functions in java 8James Brown
 
From Java 6 to Java 7 reference
From Java 6 to Java 7 referenceFrom Java 6 to Java 7 reference
From Java 6 to Java 7 reference
Giacomo Veneri
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
Łukasz Bałamut
 
Advance Java
Advance JavaAdvance Java
Advance Java
Vidyacenter
 
JDK1.7 features
JDK1.7 featuresJDK1.7 features
JDK1.7 features
india_mani
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
Leandro Coutinho
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
Ivano Malavolta
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
Mario Fusco
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
Scott Leberknight
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
HostedbyConfluent
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
javatwo2011
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondMario Fusco
 

Similar to Java7 New Features and Code Examples (20)

Java
JavaJava
Java
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
 
Lambda functions in java 8
Lambda functions in java 8Lambda functions in java 8
Lambda functions in java 8
 
55j7
55j755j7
55j7
 
From Java 6 to Java 7 reference
From Java 6 to Java 7 referenceFrom Java 6 to Java 7 reference
From Java 6 to Java 7 reference
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Advance Java
Advance JavaAdvance Java
Advance Java
 
Corba
CorbaCorba
Corba
 
JDK1.7 features
JDK1.7 featuresJDK1.7 features
JDK1.7 features
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
Jug java7
Jug java7Jug java7
Jug java7
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
 

More from Naresh Chintalcheru

Cars.com Journey to AWS Cloud
Cars.com Journey to AWS CloudCars.com Journey to AWS Cloud
Cars.com Journey to AWS Cloud
Naresh Chintalcheru
 
Bimodal IT for Speed and Innovation
Bimodal IT for Speed and InnovationBimodal IT for Speed and Innovation
Bimodal IT for Speed and Innovation
Naresh Chintalcheru
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
Naresh Chintalcheru
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
Naresh Chintalcheru
 
Problems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web ApplicationsProblems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web Applications
Naresh Chintalcheru
 
Design & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEEDesign & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEE
Naresh Chintalcheru
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
Naresh Chintalcheru
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
Naresh Chintalcheru
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
Naresh Chintalcheru
 

More from Naresh Chintalcheru (10)

Cars.com Journey to AWS Cloud
Cars.com Journey to AWS CloudCars.com Journey to AWS Cloud
Cars.com Journey to AWS Cloud
 
Bimodal IT for Speed and Innovation
Bimodal IT for Speed and InnovationBimodal IT for Speed and Innovation
Bimodal IT for Speed and Innovation
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
 
Problems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web ApplicationsProblems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web Applications
 
Design & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEEDesign & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEE
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 

Java7 New Features and Code Examples

  • 1. Java 7 New Features & Code Examples Naresh Chintalcheru
  • 2. Numeric Literals with Underscores int thousand = 1_000; int million = 1_000_000; //1000000 (one million) double d1 = 1000_000_.0d long a1 = 0b1000_1010_0010_1101_1010_0001_0100_0101L; Imagine counting tens of zero’s ?. No need to strain eyes or manual errors with Underscores
  • 3. Bracket Notation for Collection Old-Way Collection<String> c = new ArrayList(); c.add(“one”); c.add(“two”); c.add(“ten”); New-Way Collection<String> c = new ArrayList {“one”, “two”, “ten”};
  • 4. try-with-resource Old-Way BufferedReader br = null; try { br = new BufferedReader(new FileReader(path)); return br.readLine(); }catch(IOException ioEx) {} finally { try{ br.close(); }catch(IOException ioEx) {} }
  • 5. try-with-resource • The File, JDBC, MQ, LDAP & Mail resource connections will be opened & closed • The finally block is used to make sure the resources are closed • Have another try-catch for closing the resources
  • 6. try-with-resource New-Way try (BufferedReader br = new BufferedReader(new FileReader(path)); BufferedWriter bw = new BufferedWriter(new FileWriter(path)); ){ //File code } catch(IOException ioEx) { } With Java7 try-with-resource the resources BufferedReader & BufferedWriter implements java.lang. AutoCloseable and will be closed automatically
  • 7. try-with-resource New-Way try (Statement stmt = con.createStatement()) { ResultSet rs = stmt.executeQuery(query); while (rs.next()) String coffeeName = rs.getString("Name”); } catch (SQLException e) { } With Java7 try-with-resource the resource javax.sql. Statement implements java.lang.AutoCloseable and will be closed automatically
  • 8. Multi-Catch Old-Way try { //statements } catch (ExceptionOne ex) { logger.error(ex); throw ex; } catch (ExceptionTwo ex) { logger.error(ex); throw ex; } catch (ExceptionThree ex) { logger.error(ex); throw ex; }
  • 9. Multi-Catch New-Way try { //statements } catch (ExceptionOne | ExceptionTwo | ExceptionThree ex) { logger.error(ex); throw ex; } Clean code with multiple exceptions in one Catch block
  • 10. Final Rethrow void process() throws IOException, SQLException try { //statements } catch (final throw ex; } Throwable ex) { New precise rethrow feature which lets catch and throw the base exception while still throwing the precise exception from the calling method
  • 11. String in Switch Statement Finally ☺ ☺ ☺ String day; switch (day) { case "Monday": break; case "Tuesday": case "Sunday": typeOfDay = "Weekend"; break; default: throw new IllegalArgumentException("Invalid"); } .
  • 12. Simple Generic Instance Old-Way List<String> strings = new ArrayList<String>(); Map<String, List<String>> myMap = new HashMap<String, List<String>>(); New-Way (Simple) List<String> strings = new ArrayList<>(); Map<String, List<String>> myMap = new HashMap<>(); .
  • 13. Java.nio.file* (NIO2) java.nio.file.Files java.nio.file.Path java.nio.file.Paths Paths and Path - File locations/names Files - Operations on file content FileSystem – provides file services File.toPath() method, Lets older code interact with the new java.nio API .
  • 14. Create File Symbolic Link java.nio.file.Files.createSymbolicLink() createSymbolicLink() – creates a symbolic link, if supported by the file system public static Path createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException .
  • 15. Path, Files & Scanner final static Charset ENCODING = StandardCharsets.UTF_8; List<String> readFile(String aFileName) throws IOException { Path path = Paths.get(aFileName); return Files.readAllLines(path, ENCODING); //Read List } void readFile(String aFileName) throws IOException { Path path = Paths.get(aFileName); try (Scanner scanner = new Scanner(path, ENCODING.name())){ while (scanner.hasNextLine()){ log(scanner.nextLine()); //Read String Line } }} .
  • 16. Path & Files To Write final static Charset ENCODING = StandardCharsets.UTF_8; void writeFile(List<String> aLines, String aFileName) throws IOException { Path path = Paths.get(aFileName); Files.write(path, aLines, ENCODING); //Write using List } void writeFile(String aFileName, List<String> aLines) throws IOException { Path path = Paths.get(aFileName); try (BufferedWriter writer = Files.newBufferedWriter(path, ENCODING)){ for(String line : aLines){ writer.write(line); //Write String line writer.newLine(); } }}.
  • 17. File Change Notifications File Change Notifications with WatchService APIs private void watch() { Path path = Paths.get("C:Temptemp"); try { watchService = FileSystems.getDefault().newWatchService(); path.register(watchService, ENTRY_CREATE, ENTRY_DELETE, } catch (IOException e) { System.out.println("IOException"+ e.getMessage()); } } ENTRY_MODIFY);
  • 18. Streaming & Channel-based I/O • A stream is a contiguous sequence of data. Stream IO acts on a single character at a time, while channel IO works with a buffer for each operation. • These are supported by the Files class and Buffered IO is usually more efficient to be used in reading and writing data. • The java.nio.channels package's ByteChannel interface is a channel that can read and write bytes. • The SeekableByteChannel interface extends the ByteChannel interface to maintain a position within the channel. The position can be changed using seek type random IO operations.
  • 19. Asynchronous Channel-based I/O Support for Asynchronous channel-based I/O functionality • AsynchronousFileChannel class is used for file manipulation operations that need to be performed in an asynchronous manner, the methods supporting the File write and read operations. • AsynchronousChannelGroup class provides a means of grouping asynchronous channels together in order to share resources. • Java.nio.file package's SecureDirectoryStream class provides support for more secure access to directories. However, the underlying operating system must provide local support for this class.
  • 20. URLClassLoader Closing The URLClassLoader.close() method eliminates the problem of supporting updated implementations of the classes and resources loaded from a particular codebase, and in particular from JAR files.
  • 21. URLClassLoader Closing URL url = new URL("file:foo.jar"); URLClassLoader loader = new URLClassLoader (new URL[] {url}); Class cl = Class.forName ("Foo", true, loader); Runnable foo = (Runnable) cl.newInstance(); foo.run(); loader.close (); // foo.jar gets updated somehow loader = new URLClassLoader (new URL[] {url}); cl = Class.forName ("Foo", true, loader); foo = (Runnable) cl.newInstance(); // run the new implementation of Foo foo.run(); Eliminates Server restarts
  • 22. JDBCRowSet The RowSetFactory interface and the RowSetProvider class, which enable you to create all types of row sets supported by the JDBC driver. RowSetFactory myRowSetFactory = RowSetProvider.newFactory(); JdbcRowSet jdbcRs = myRowSetFactory.createJdbcRowSet(); jdbcRs.setUrl("jdbc:driver:myAttribute"); jdbcRs.setUsername(username); jdbcRs.setPassword(password); jdbcRs.setCommand("select * from Emp"); jdbcRs.execute(); jdbcRs.moveToInsertRow(); jdbcRs.updateInt(“AGE", 0); jdbcRs.insertRow(); jdbcRs.last(); jdbcRs.deleteRow();
  • 23. Varargs public class VarArgsJavav6 { public static void main(String[] args) { vaMethod("a", "b", "c"); } public void vaMethod(String... args) { for(String s : args) System.out.println(s); } } Automatically treats Method parameter as an Array
  • 24. JVM G1 Garbage Collector • The Garbage-First (G1) garbage collector achieves high performance and pause time goals through several techniques • The G1 collector is a server-style garbage collector, targeted for multi-processor machines with large memories • Meets garbage collection (GC) pause time goals with high probability, while achieving high throughput.
  • 25. Dynamic Language Support • Java is a static typed language to make it little bit more dynamic (long way to go) similar to dynamic typed languages like Ruby, Python & Clojure the new package java.lang. invoke is introduced • A new package java.lang.invoke includes classes MethodHandle, CallSite and others, has been created to extend the support of dynamic languages .
  • 26. Java 7 Performance Improved String Performance Improved Array Performance Security Enhancements Support for Non-Java Languages - invokedynamic