More java static and final abstract class and interface exceptions collections framework
This presentation is the property of its rightful owner.
Sponsored Links
1 / 18

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


  • 95 Views
  • Uploaded on
  • Presentation posted in: General

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 .

Download Presentation

More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework

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


Java vs c classes interfaces

Java vsC#: Classes / Interfaces

CS300


Java vs c classes interfaces1

Java vsC#: Classes / Interfaces

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


Java vs c exception handling

Java vsC#: Exception Handling

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


Java generics

Java Generics

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


  • Login