Hashmap, date, exception Android Club 2015. Agenda Hashmap Date Exception handling.

Slides:



Advertisements
Similar presentations
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Server-Side Scripting with JSP (2) ISYS 350. Post Back A postback is call to the same page that the form is on. In other words, the contents of the form.
L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
CS 206 Introduction to Computer Science II 01 / 20 / 2009 Instructor: Michael Eckmann.
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
CS324e - Elements of Graphics and Visualization A Little Java A Little Python.
Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
CS102--Object Oriented Programming
13 Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Handling Errors.
Java Programming Exceptions. Java has a built in mechanism for error handling and trapping errors Usually this means dealing with abnormal events or code.
Exception Handling. 2 Two types of bugs (errors) Logical error Syntactic error Logical error occur  due to poor understanding of the problem and solution.
CS 206 Introduction to Computer Science II 09 / 09 / 2009 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
Lecture 7: Arrays Yoni Fridman 7/9/01 7/9/01. OutlineOutline ä Back to last lecture – using the debugger ä What are arrays? ä Creating arrays ä Using.
Chapter 8 Overview – Learn to use try catch blocks – Learn to use streams – Learn to use text files.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional.
XML Android Club Agenda XML JSON XML eXtensible Markup Language Used for: data transfer PHP -> Java.
Introduction to Computer Programming Error Handling.
CS1101: Programming Methodology Aaron Tan.
1 Web Based Programming Section 6 James King 12 August 2003.
Classes, Objects, Arrays, Collections and Autoboxing Dr. Andrew Wallace PhD BEng(hons) EurIng
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Exception Handling. 2 Two types of bugs (errors) Logical error Syntactic error Logical error occur  Due to poor understanding of the problem and solution.
Jun 16, 2014IAT 2651 Debugging. Dialectical Materialism  Dialectical materialism is a strand of Marxism, synthesizing Hegel's dialectics, which proposes.
1 Documenting Your Project. 2 Documenting your Project Insert Banner Comments in your code Comment - coding statement used by humans not the compiler.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
File Management Android Club Agenda Working with files Networking XML JSON.
Chapter 8: Collections: Arrays. 2 Objectives One-Dimensional Arrays Array Initialization The Arrays Class: Searching and Sorting Arrays as Arguments The.
JSP Exception Handling 20-Oct-15. JSP - E XCEPTION H ANDLING When you are writing JSP code, a programmer may leave a coding errors which can occur at.
Problem of the Day  Why are manhole covers round?
Data collections Android Club Agenda Array ArrayList HashMap.
1 Three C++ Looping Statements Chapter 7 CSIS 10A.
CSE 232: C++ debugging in Visual Studio and emacs C++ Debugging (in Visual Studio and emacs) We’ve looked at programs from a text-based mode –Shell commands.
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.
Lin Chen 09/13/2011. Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value);
CSE 332: C++ debugging Why Debug a Program? When your program crashes –Finding out where it crashed –Examining program memory at that point When a bug.
FT228/3 Web Development Error processing. Introduction READ Chapter 9 of Java Server Pages from O’reilly 2 nd Edition Need to be able to 1) Diagnose and.
Primitive variables Android Club types of variables: Primitive single value (starts with uppercase letter) Complex multiple value (starts with.
Server-Side Scripting with JSP (2) ISYS 350. Java Array Examples of declaring an array: – int[] anArray = new int[10]; 10 elements index from 0 to 9 –
Research Topics in Computational Science. Agenda Commenting Our Code Variable Review Button Program – Add Textbox Getting text from textbox Converting.
C Programming – Part 3 Arrays and Strings.  Collection of variables of the same type  Individual array elements are identified by an integer index 
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Condition & loop Android Club Agenda if/else Switch Loops.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 22: Pointers.
Testing Chapter 23 IB103 Week 12 (part 3). Verify that a complex (any) program works correctly, that the program meets specifications The chapter reviews.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter Array Basics.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
CSC Java Programming, Fall, 2008 Week 3: Objects, Classes, Strings, Text I/O, September 11.
Swift. Introduced in 2014 Replaces Objective-C as “recommended development language” “safer, succinct, readable” Emphasizes type safety.
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Pointers as arrays C++ Programming Technologies. Pointers vs. Arrays Pointers and arrays are strongly related. In fact, pointers and arrays are interchangeable.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Asif Nawaz University Institute of Information Technology, PMAS-AAUR Lecture 05: Object Oriented Programming:2014 Object-Oriented Programming in C++ Exception.
Java Expert Session By: Prof. Mehul Raval Prof. Adarsh Patel Prof. Mihir Suthar.
Chapter 2 Assignment and Interactive Input
Computer Programming I
Arrays, For loop While loop Do while loop
Exception Handling in Java
design OO words Debug Variables Data types
Nate Brunelle Today: Dictionaries
Exceptions Review Checked Vs. Unchecked Exceptions
Presentation transcript:

Hashmap, date, exception Android Club 2015

Agenda Hashmap Date Exception handling

HashMap Unordered list Based on key-value

HashMap: example HashMap countryCodes = new HashMap (); countryCodes.put("UZ", "Uzbekistan"); countryCodes.put("JP", "Japan"); countryCodes.put("US", "United States"); System.out.println(countryCodes.get("UZ" ));

HashMap: practice Create HashMap: elements Key: String Value: String Add values: H – Hydron O – Oxygen N – Nitrogen Print Oxygen

HashMap: practice 2 Create Hashmap: httpCodes Key: int Value: String 404 – Not found 403 – Forbidden 400 – Bad request Print “Not found”

HashMap: practice 3 Create HashMap: capitals Key: String Value: String Uzbekistan – Tashkent Japan – Tokyo US – Washington Print Japan’s capital city

Date Date d = new Date(); System.out.println(d);

SimpleDateFormat: date Date d = new Date(); SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(sdfDate.format(d));

Documentation va/text/SimpleDateFormat.htmlhttp://docs.oracle.com/javase/8/docs/api/ja va/text/SimpleDateFormat.html

SimpleDateFormat: time SimpleDateFormat sdfTime = new SimpleDateFormat("hh:mm:ss"); System.out.println("Time:"+sdfTime.forma t(d));

SimpleDateFormat: practice Show: AM or PM

SimpleDateFormat: practice2 Show hour in 0-23 format: PM 07:35:45 -> 19:35:45

SimpleDateFormat: practice3 Create new SimpleDateFormat: sdfYearWeek Week in year: XX Create new SimpleDateFormat: sdfMonthWeek Week in month: XX

SimpleDateFormat: practice4 Show weekday in number: 1 Show weekday in text: Monday

Error Compile time error Run time error

Compile time error String name = "Joe"

Compile time error: practice Create String: without any value Print String

How to handle: compile Fix it!

Run time error String[] names = {"Joe"}; System.out.println(names[1]);

Run time error: practice Create char array: abc Print index 5 value

Try-catch try { String[] names = {"Joe"}; System.out.println(names[1]); } catch (Exception e) { e.printStackTrace(); }

Try-catch block: practice int x = 5; int y = 0; System.out.println(x/y); System.out.println(x+y);

Try-catch: practice2 String[] names = {"Joe"}; System.out.println(names[-1]);

Debugger bug Debug Debugging Debugger

Debugger: example int sum = 0; for (int i = 0; i < 10; i++) { int square = i^2; sum+=square; } System.out.println(sum);

Debugger: practice Create new class Create main method Calculate sum of numbers from 1 to 10 inclusive Check every step using debugger

Questions? Any questions!

Review 8-4 Hashmap 6-4 Date Chapter 7 – Exception handling

Thank you! Thank you for your attention!