[ ] Questions [ ] Lab / HW Notes [ ] try/catch blocks – keep control [ ] Notes - Documentation – what was changed - names – single characters –no sentenceAnalysis.

Slides:



Advertisements
Similar presentations
Intro to Scala Lists. Scala Lists are always immutable. This means that a list in Scala, once created, will remain the same.
Advertisements

Notes from HW3 / Lab3 Program documentation – At the top of every class: //************************************************************ // seu01.java Author:
Written by: Dr. JJ Shepherd
Chapter 7: User-Defined Functions II
Lecture 23 Input and output with files –(Sections 2.13, 8.7, 8.8) Exceptions and exception handling –(Chapter 17)
CS102--Object Oriented Programming
More Java Syntax. Scanner class Revisited The Scanner class is a class in java.util, which allows the user to read values of various types. There are.
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.
[ ] Review Exam [ ] Questions [ ] Lab 6 [ ] HW6 [ ] Method Block Diagram [ ] Methods, methods [ ] Looping constructs [ ] for loop [ ] ++, -- (Thursday)
CPSC150 Click to edit Master title style Click to edit Master text styles Second level Third level Fourth level Fifth level 1 CPSC150 Exceptions When things.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Announcements The first graded lab will be posted Sunday 2/15 and due Friday 2/27 at midnight It is brand new, so please don’t hand in last semester’s.
DT211/3 Internet Application Development
Exceptions COMP53 Sept Exceptions An exception is an object that gets thrown to indicate an error or other exceptional condition. Using exceptions.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
CSE 332: C++ program structure and development environment C++ Program Structure (and tools) Today we’ll talk generally about C++ development (plus a few.
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
Introduction to Java. Main() Main method is where the program execution begins. There is only one main Displaying the results: System.out.println (“Hi.
Introduction to Computer Programming Error Handling.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Review COMP 102 #
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Week #2 Java Programming. Enable Line Numbering in Eclipse Open Eclipse, then go to: Window -> Preferences -> General -> Editors -> Text Editors -> Check.
Coding Methodology How to Design Code. © 2005 MIT-Africa Internet Technology Initiative Pay Attention to Detail When implementing or using APIs details.
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 10.
EXAM 1 REVIEW. days until the AP Computer Science test.
CSc2310 tutoring session, week 8 Fall, 2012 Haidong Xue 5:30pm—8:30pm 11/06/2012 and 11/07/2012 -Test 3 Study Guide.
Chapter 2 Using Objects. Types A type defines a set of values and the operations that can be carried out on the values Examples: 13 has type int "Hello,
BIO Java 1 Exception Handling Aborting program not always a good idea – can’t lose messages – E-commerce: must ensure correct handling of private.
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.
ECE 122 Feb. 1, Introduction to Eclipse Java Statements Declaration Assignment Method calls.
Copyright Curt Hill Variables What are they? Why do we need them?
ITI 1120 Lab #5 Contributors: S. Boyd, R. Plesa, A. Felty, D. Inkpen, A. Williams, D. Amyot.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Sheet 3 HANDLING EXCEPTIONS Advanced Programming using Java By Nora Alaqeel.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
CS1101 Group1 Discussion 10 Lek Hsiang Hui comp.nus.edu.sg
Week 61 Introduction to Programming Ms. Knudtzon C Period Tuesday October 12.
Welcome to AP Computer Science A We use the Java language, but this class is much more rigorous than Intro to Java More programming, but also more theory.
1 CSE 142 Midterm Review Problems These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or modified.
Written by: Dr. JJ Shepherd
A High Flying Overview CS139 – Fall 2006 How far we have come.
Special Methods in Java. Mathematical methods The Math library is extensive, has many methods that you can call to aid you in your programming. Math.pow(double.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
1 CSE 142 Final Exam Review Problems. 2 Question Types expressions array mystery inheritance mystery file processing array programming Critters classes.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Object Oriented Programming Lecture 2: BallWorld.
A High Flying Overview CS139 – Fall 2010 How far we have come.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Repetition Statements
Exceptions: When things go wrong
Lecture 10: More on Methods and Scope
Agenda Warmup Lesson 2.5 (Ascii, Method Overloading)
CS139 – Fall 2010 How far we have come
Chapter 6 Sub Procedures
Advanced Java Programming
Introduction to Classes and Methods
Fundamental Error Handling
CIS 110: Introduction to Computer Programming
Chapter 4: Repetition Structures: Looping
Question 1a) What is printed by the following Java program? int s;
Chapter 2 Primitive Data Types and Operations
Variables in C Topics Naming Variables Declaring Variables
Random Numbers while loop
More on iterations using
Presentation transcript:

[ ] Questions [ ] Lab / HW Notes [ ] try/catch blocks – keep control [ ] Notes - Documentation – what was changed - names – single characters –no sentenceAnalysis and all other methods - String is capitalized, double is not - method parameter list - method signature [ ] what is an object? Book, chair, freshman ap, student, classroom, biographical info

[ ] Lab / HW Notes - Loop endpoints are killers - Index out of range exception --- charAt(0) - In a for loop, DO NOT MUCK WITH THE INDEX - No single letter variable names (convention??) - total += count; what does this do? total = total + count; - Initialize all variables when declared - Study together – doing this class by yourself is really difficult - Ask questions

Java throws exceptions all over the place That’s good news – java is trying to help take care of us. So what tools can we use to maintain control? That’s really the issue – maintain control of your programs. If we try something and it works fine – great, no worry But if we try something and it blows up, we would like to be able to recover so we are not embarrassed

What could possibly go wrong? “Please enter an integer:” $ oh man!! What is the 4 th character of String S1 = “Hi!”; Well, it is S1.charAt(3) oh man!! The first is an InputMismatchException The second is an IndexOutOfBoundsException Why??? On both?

Help us out java: try { something if it works – great, continue on } catch (Exception somevariablename) { here’s our chance to avoid losing control – we catch the exception that java throws and handle it the way we want. } … java program continues

Examples see links on our web page tryCatch2.java tryCatch3.java tryCatch4.java Trouble in River City Trouble in River City – the reason for try/catch blocks

for ( ; ; ) { } Pre-condition loop loop-controlled What is the ‘for-body’ Is the index automatically incremented? When? What goes in all the blank areas?

for ( starting index ;logical expression; index mover) { for body index++ } The ‘index mover’ is implicit – automatically done on way up. Note: DO NOT MUCK WITH AN INDEX

for ( int index = 0; index < 5; index++) { System.out.prinln(“hello!”); } Hand trace Output

Images --- METHOD

// Pre: type1, type2 // Post: retobty (type of returned object) public static retobty mName(type1 name1, type2 name2) { method body } Method signature mName: type1, type2

Images --- Scanner

Images --- Scanner

Images --- Scanner

- Do not get paralyzed - Draw a picture - Write a story - What is the concept? - The helicopter perspective? Who’s in control – you or the CA?