SlideServe
Menu
Préférences
© SlideServe · v2026

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

brone avatar
18 diapositives · 377 Views · Jul 17, 2014

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 .

More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework - slide 1
01 / 18More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework
1 / 17

Télécharger la présentation

More Java: Static and Final, Abstract Class and Interface, Exceptions , Collections Framework
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. More Java: Static and Final, Abstract Class and Interface, Exceptions, Collections Framework CS300

  2. 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

  3. Java vsC#: Classes / Interfaces CS300

  4. Java vsC#: Classes / Interfaces CS300

  5. 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

  6. Exceptions • Handle unusual conditions CS300

  7. Java vsC#: Exception Handling CS300

  8. 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

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

  14. 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

  15. 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

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

  17. Java Generics CS300

  18. 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