 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 

Slides:



Advertisements
Similar presentations
Chapter 17 Failures and exceptions. This chapter discusses n Failure. n The meaning of system failure. n Causes of failure. n Handling failure. n Exception.
Advertisements

Chapter 11 Introduction to Programming in C
Exception Handling The purpose of exception handling is to permit the program to catch and handle errors rather than letting the error occur and suffer.
COMP 121 Week 5: Exceptions and Exception Handling.
CSE 332: C++ exceptions Overview of C++ Exceptions Normal program control flow is halted –At the point where an exception is thrown The program call stack.
Exceptions Any number of exceptional circumstances may arise during program execution that cause trouble import java.io.*; class IOExample { public static.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
1 / 89 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 11 Programming Fundamentals using Java 1.
Exception Handling Introduction Exception handling is a mechanism to handle exceptions. Exceptions are error like situations. It is difficult to decide.
11-Jun-15 Exceptions. 2 Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a.
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
1 From Yesterday private = accessible only to the class that declares it public = accessible to any class at all protected = accessible to the class and.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
Exceptions Objectives At the conclusion of this lesson, students should be able to Explain the need for exceptions Correctly write programs that use.
Chapter 11: Handling Exceptions and Events J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Fourth.
Chapter 7 Improving the User Interface
12.1 Exceptions The limitations of traditional methods of exception handling Error conditions are a certainty in programming Programmers make.
Exceptions. Many problems in code are handled when the code is compiled, but not all Some are impossible to catch before the program is run  Must run.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Exception Handling in Java Course Lecture Slides 7 th July 2010 “ Admitting.
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.
What is an exception? An exception is: – an event that interrupts the normal processing of the program. –an error condition that violates the semantic.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 18 Exception Handling.
CPSC 252 Exception Handling Page 1 Exceptions and exception handling Client programmers can make errors using a class attempting to dequeue an item from.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
06 Exception Handling. 2 Contents What is an Exception? Exception-handling in Java Types of Exceptions Exception Hierarchy try-catch()-finally Statement.
Lesson 7: Improving the User Interface
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Data Structures and Java CS 105. L7: Java Slide 2 Data structure Data structure defined: A systematic way of organizing and accessing data Examples Dictionary:
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.
Exceptions Handling Exceptionally Sticky Problems.
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.
Exception Handling in JAVA. Introduction Exception is an abnormal condition that arises when executing a program. In the languages that do not support.
Introduction to Exception Handling and Defensive Programming.
Best Practices. Contents Bad Practices Good Practices.
BIO Java 1 Exception Handling Aborting program not always a good idea – can’t lose messages – E-commerce: must ensure correct handling of private.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Sheet 3 HANDLING EXCEPTIONS Advanced Programming using Java By Nora Alaqeel.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 11 Handling Exceptions and Events.
09/13/12All Rights Reserved - ADVANTEST CORPORATION1 Java 7 Highlights Presented By: Andrey Loskutov.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Exceptions and Assertions Chapter 15 – CSCI 1302.
CSE 332: C++ Statements C++ Statements In C++ statements are basic units of execution –Each ends with ; (can use expressions to compute values) –Statements.
Exception-Handling Fundamentals  A Java exception is an object that describes an exceptional (that is, error) condition that has occurred in a piece of.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
GROUPING OBJECTS CITS1001. Lecture outline The ArrayList collection Process all items: the for-each loop 2.
Chapter 8-Exception Handling/ Robust Programming.
1 Exceptions. 2 Syntax Errors, Runtime Errors, and Logic Errors syntax errors, runtime errors, and logic errors You learned that there are three categories.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
C# Exceptions 1 CNS 3260 C#.NET Software Development.
ITP 109 Week 2 Trina Gregory Introduction to Java.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Lecture 5: Exception Handling and Text File I/O Michael Hsu CSULA.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
3-July-2002cse142-D2-Methods © 2002 University of Washington1 Methods CSE 142, Summer 2002 Computer Programming 1
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Introduction to Java Import Scanner class to use in our program
CNS 3260 C# .NET Software Development
Chapter 11 Introduction to Programming in C
Exception Handling in Java
Exceptions 25-Apr-19.
Exceptions 22-Apr-19.
LCC 6310 Computation as an Expressive Medium
Exceptions 5-Jul-19.
Presentation transcript:

 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  ‘free’ support for Java 1.6 stops this summer  Have to pay afterwards  We can’t specify 1.7 in our JNLP files a JaWS would need internet access to download 1.7 JRE  Many other new features, but I’ll outline what was interesting for me…

 Just like primitive switch()  switch (dayOfWeekArg) { case "Monday": …  Java compiler generates generally more efficient bytecode from switch statements that use String objects than from chained if-then- else statements

 int toto4 = 5_______2;  Why? Readability!  Not everywhere though  3_.1415 <- Not next to a decimal point  999_99_9999_L <- Not next to F or L suffix  52_ <- Not at the end of a literal  0_x45 <- Can’t separate 0x!  Rule is that if it doesn’t make it more readable, it’s invalid!

 Now we can have literals expressed in binary  0b or 0B prefix (like 0x/0X for hex)  0b  This can make bit patterns much easier to understand than using hexadecimal for example  Same rules for 64 bits apply as decimal  0b L

 Typing reduced  Map > myMap = new HashMap >();  …becomes…  Map > myMap = new HashMap<>();  Compiler knows what it’s expecting so infers it automatically!

 Often several exceptions are thrown from a single call to a method  Java 7 allows you to ‘OR’ the exceptions in the catch statement  try{…}catch (IOException|SQLException ex) { }  Also, you can promote a class to a subclass in the throws declaration  Void toto(String s) throws AEx, BEx { try { //... } catch (Exception e) { throw e; } }  The compiler checks that e is indeed of type Aex or Bex  This is really useful when catching many exceptions (generically) and rethrowing them with more inclusive type checking

 You can now ‘monitor’ files or directories  Can be used as a handy inter-process- communication mechanism  Used in FESA 3 Navigator (using 3 rd party library at the moment)  ‘notify me when a new file appears in a directory’  Uses native system calls (ReadDirectoryChangesW / iNotify on Windows / Linux)  On other platforms falls back to polling

 Very poor info prior to Java 7  Metadata (size, owner, creation time, etc)  Also isSymbolicLink(Path)isSymbolicLink(Path)  ?etPosixFilePermissions(Path, LinkOption...) ?etPosixFilePermissions(Path, LinkOption...)  … + a lot more attributes depending on file system (windows, posix etc)  Can now give much better error messages when something goes wrong with a file access  Previously you just got ‘false’ when trying to do many file operations!  File systems info as well

 Previously it was very cumbersome to intialise Lists/Sets/Maps etc.  Inialising Lists  List list = ["item"];  Accessing Lists  String item = list[0];  Initializing Sets  Set set = {"item"};  Maps…  Map map = {"key" : 1}; int value = map["key"];  Etc…  Result is much less code and typing!

 We should take care not to use any new features in Java 7 if we intend to use in CCC  We _could_ use from our terminal servers  Main benefits are for IO (Sockets, NIO.2 not in detail here)  But lots of nice language modifications  Less typing!  We now wait for CO!