more java static and final abstract class and interface exceptions collections framework
Download
Skip this Video
Download Presentation
More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework

Loading in 2 Seconds...

play fullscreen
1 / 18

More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework - PowerPoint PPT Presentation


  • 163 Views
  • Uploaded on

More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework . Abstract class and interface. Abstract class : Declaration omitting implementation Interface : a "contract" that spells out how software interacts .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework ' - brone


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
more java static and final abstract class and interface exceptions collections framework
More Java: Static and Final, Abstract Class and Interface, Exceptions, Collections Framework

CS300

abstract class and interface
Abstract class and interface
  • Abstract class: Declaration omitting implementation
  • Interface: a "contract" that spells out how software interacts.
  • Example: sort contacts on your phone based on e-mail addresses

CS300

static and final
Static and Final
  • Final declaration cannot be changed
    • Classes, methods, fields, parameters and local variables can be final
  • Static: belongs to the class in which it is described, not an instance of a class
    • Example:
      • Download QuietStatic.java and LoudStatic.java
      • Create StaticClientfor QuietStatic where you increment class member and instance member
      • Fill in LoudStatic

CS300

exceptions
Exceptions
  • Handle unusual conditions

CS300

collection framework
Collection framework
  • One of the most powerful and convenient tools of Java
  • java.util package: http://docs.oracle.com/javase/6/docs/api/java/util/Collections.html

CS300

collection interface types
Collection interface types
  • Collection: root type. Group of objects, not necessarily ordered, not necessarily addressable, possibly containing duplicates. You can:
    • Add/remove things from it
    • Get its size
    • Iterate over it

CS300

collection interface types1
Collection interface types
  • List: ordered collection, index from 0 to length -1. May contain duplicates. You can:
    • Add/remove things from it
    • Get its size
    • Iterate over it
    • Map an element to its index
    • Map an index to an element
    • Change an element at a specific index

CS300

collection interface types2
Collection interface types
  • Set: unordered collection. Does not contain duplicates. You can:
    • Add/remove things from it
    • Get its size
    • Iterate over it
  • Map: like a list. Instead of mapping a collection of objects to integer indexes, it maps them to a set of key objects
    • Examples:mapping of words to their definitions, dates to events, or URLs to cached content

CS300

collection interface types3
Collection interface types
  • What you can do with a Map:
    • Add/remove things from it
    • Get its size
    • Iterate over it
    • Map an element to its key
    • Map keyto an element
    • Change an element at a specific key

CS300

collection interface types4
Collection interface types
  • Iterator: Returns elements from a collection from which it is derived, exactly once, in response to calls to its next method.

CS300

collection implementation types
Collection implementation types
  • ArrayList: list implemented by an array.
    • Quick to index
    • Slow to change size
  • LinkedList: list that can change size quickly but it is slower to index.

CS300

collection implementation types1
Collection implementation types
  • HashSet: set that is implemented as a hash.add, remove, contains, and size all execute at constant time assuming well behaved hash. May contain no more than one null.
  • HashMap: implementation of Map that uses hash table as its index. add, remove, contains, and size all execute at constant time assuming well behaved hash. May contain a single null key but any number of values may be null.

CS300

collection implementation types2
Collection implementation types
  • TreeMap: orderedMap, objects in the map are sorted according to their natural order, or according to Comparator.

CS300

references
References
  • Programming Android by ZigurdMednieks, Laird Dornin, G. Blake Meike, Masumi Nakamura
  • Exceptions http://docs.oracle.com/javase/6/docs/api/java/lang/Exception.html

CS300

ad