20-Oct-15 Java 7. The diamond operator Instead of HashMap > map = new HashMap >(); you can now say HashMap > map = new HashMap<>; In fact, if you don’t.

Slides:



Advertisements
Similar presentations
wwwcsif.cs.ucdavis.edu/~jacksoni
Advertisements

11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
1 pritisajja.info Unlocking the World of Java Programming….. Priti Srinivas Sajja February, 2014 Visit pritisajja.info for detail Future Technology for.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Java Basic Training HaiNH - FQA. Agenda Introduction to Java Java Programming Environment Language Fundamental Object Oriented Programming with Java.
1 Java Programming Basics SE-1011 Dr. Mark L. Hornick.
Text File I/O. Text Files and Binary Files Files that are designed to be read by human beings, and that can be read or written with an editor are called.
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
Outline Java program structure Basic program elements
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Java Course Outline Kumar Harshit, USW. Course Description Teaches students to program using the Java programming language with the help of the Netbeans.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
Java Programming Robert Chatley William Lee
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Abstract Data Types (ADTs) and data structures: terminology and definitions A type is a collection of values. For example, the boolean type consists of.
Intro to Programming Lecture 13
Java Virtual Machine Java Virtual Machine A Java Virtual Machine (JVM) is a set of computer software programs and data structures that use.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
CSC204 – Programming I Lecture 4 August 28, 2002.
 No move to Java 7 until end of this year  IT deploy Java 7 everywhere  BE/CO remove it again!  So don’t rely on it being installed on a console 
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Exception. Runtime Error Consider the following program: public class BadArray { public static void main(String[] args) { // Create an array with three.
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
CMSC 202 Text File I/O. Aug 8, Text Files and Binary Files Files that are designed to be read by human beings, and that can be read or written with.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
09/13/12All Rights Reserved - ADVANTEST CORPORATION1 Java 7 Highlights Presented By: Andrey Loskutov.
Object Oriented Programming (OOP) LAB # 1 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
Java Security cont’d. Using SecurityManager  The basic SecurityManager architecture is simple. Throughout the JDK, the Java security team had to:  Identify.
Java FilesOops - Mistake Java lingoSyntax
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
OOP Tirgul 7. What We’ll Be Seeing Today  Packages  Exceptions  Ex4 2.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
Sachin Malhotra Saurabh Choudhary
Information and Computer Sciences University of Hawaii, Manoa
OBJECT ORIENTED PROGRAMMING
JAVA MULTIPLE CHOICE QUESTION.
Working with Java.
GC101 Introduction to computer and program
Internet and Java Foundations, Programming and Practice
Lecture 30 Revision Lecture 1
Java Intro III.1 (Fr Feb 23).
null, true, and false are also reserved.
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Chapter 1: Computer Systems
Exception Handling in Java
Sridhar Narayan Java Basics Sridhar Narayan
A type is a collection of values
Presentation transcript:

20-Oct-15 Java 7

The diamond operator Instead of HashMap > map = new HashMap >(); you can now say HashMap > map = new HashMap<>; In fact, if you don’t use this abbreviation, Eclipse may produce a warning message 2

Strings in switch statements Instead of if (input.equals(“yes”)) { return true; } else if (input.equals(“no”)) { return false; } else { askAgain(); } you can now say switch(input) { case “yes”: return true; case “no”: return false; default: askAgain(); } 3

Automatic resource management Instead of public void oldTry() { try { fos = new FileOutputStream("movies.txt"); dos = new DataOutputStream(fos); dos.writeUTF("Java 7 Block Buster"); } catch (IOException e) { e.printStackTrace(); } finally { try { fos.close(); dos.close(); } catch (IOException e) { // log the exception } } } You can now say: public void newTry() { try (FileOutputStream fos = new FileOutputStream("movies.txt"); DataOutputStream dos = new DataOutputStream(fos)) { dos.writeUTF("Java 7 Block Buster"); } catch (IOException e) { // log the exception } } 4

Underscores in numbers Instead of int million = ; you can now say int million = 1_000_000; 5

Multi- catch public void newMultiMultiCatch() { try { methodThatThrowsThreeExceptions(); } catch (ExceptionOne e) { // deal with ExceptionOne } catch (ExceptionTwo | ExceptionThree e) { // deal with ExceptionTwo and ExceptionThree } } 6

New java.nio.file package A new java.nio.file package consists of classes and interfaces such as Path, Paths, FileSystem, FileSystems and others. public void pathInfo() { Path path = Paths.get("c:\\Temp\\temp"); System.out.println("Number of Nodes:" + path.getNameCount()); System.out.println("File Name:" + path.getFileName()); System.out.println("File Root:" + path.getRoot()); System.out.println("File Parent:" + path.getParent()); } 7

File change notifications There is now a package that allows your program to “watch” a file and receive a notification when it is changed (by something external to your program) See java.nio.file.WatchService for details 8

Other new features Java 7 has new support for concurrency in the java.util.concurrent package We will discuss concurrency in some detail later in this course Because the Java Virtual Machine (JVM) provides excellent platform independence, and because the Java library is so extensive, many modern languages compile to ByteCode There are JVM versions of Ruby, Python, and Clojure, among others However, these are dynamic languages, for which the JVM does not provide great support (Java is a static language) The new java.lang.invoke package doesn’t help Java, but it provides better support for dynamic languages 9

The End 10