Presentation is loading. Please wait.

Presentation is loading. Please wait.

George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8.

Similar presentations


Presentation on theme: "George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8."— Presentation transcript:

1 George Blank University Lecturer

2 CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8

3 Application Frameworks Java has an extensive collection of application frameworks, collections of cooperating classes that can be used in developing applications. Chapter 8 emphasizes three such frameworks—collections, input/output and GUIs using AWT and Swing.

4 Expected knowledge Students should not only understand and be able to use the classes described in the text, but must also develop skill in using Java documentation to go beyond the material in the text. It is recommended that students become familiar with http://java.sun.com/reference/docs/index.html http://java.sun.com/reference/docs/index.html Another good site: http://javadocs.org/http://javadocs.org/

5 Chapter notes There is so much in this chapter that I hesitate to add more to the readings. I do recommend that students make certain that they understand the topics described in the chapter summary.

6 Abstract Collection Types A bag or multiset is an unordered collection of elements that may include duplicates. A bag, in Java the Collection interface, is the least restrictive and most general form of collection. A set is an unordered collection of elements without duplicates. A list is an ordered collection of elements. A map, dictionary or associative array is an unordered collection of key-value pairs.

7 Methods of Interface Collection add(element) addAll(collection) clear() contains(element) containsAll(collection) isEmpty() iterator() remove(element) removeAll(collection) retainAll(collection) size()

8 Methods of Interface List add(i,element) add(element) addAll(collection) addAll(i,collection) get(i) indexOf(element) lastIndexOf(element) containsAll(collection) listIterator() listIterator(i) remove(i) remove(element) removeAll(collection) set(i,element) subList(i,j)

9 Methods of Interface Map clear() containsKey(k) containsValue(v) entrySet() get(k) isEmpty() keySet() put(k,v) put(map) remove(k) removeAll(collection) size() values() k = key v = value

10 Types of Sets A HashSet stores elements in a hash table. A LinkedHashSet is an ordered hash table. A TreeSet stores elements in a balanced binary tree.

11 Concrete Collections Sets HashSet LinkedHashSet TreeSet 1 Lists Array List Linked List Vector Maps HashMap IndentityHashMap LinkedHashMap TreeMap 1 Hashtable 1 sorted

12 Ordering An order (technically a partial order) is a transitive binary relationship between two objects. Organized by some criteria, if a has a certain relationship with b and b has the same relationship with c, then a has that relationship with c. A sorted collection is one that orders its elements by a particular relationship.

13 Defining Orders on Objects A class can define a natural order among its instances by implementing the comparable interface. Arbitrary orders among different objects can be defined by comparators, or classes that by implement the comparator interface. SortedSet and SortedMap are sorted abstract collections that inherit the functions of sets and maps respectively.

14 Word Frequency example The Class WordFrequency2 on pages 327-328 shows an example of using a sorted map sorted by their natural keys. It first orders the words in a piece of text and then counts the identical words to determine their frequency. Class WordFrequency4 on page 332 extends this to sort the result and display the words in frequency order.

15 Java Graphical User Interfaces Java has a GUI framework consisting of several categories of classes: GUI Components (widgets) have a characteristic appearance (look) and behavior (feel). Layout managers package components in windows. (see FlowLayout and BorderLayout ) Events and Event Listeners Grapics and Imaging classes

16 Abstract Windows Toolkit The basic Java GUI toolkit is the Abstract Windows Toolkit (AWT) The Swing package is an extension of AWT to build high quality GUIs. Review the hierarchy of awt at http://java.sun.com/j2se/1.5.0/docs/api/java/awt/package-tree.html to see the wde variety of classes available to build GUI applications. http://java.sun.com/j2se/1.5.0/docs/api/java/awt/package-tree.html The Java Class hierarchy is a good starting place to understand Java libraries: http://java.sun.com/j2se/1.5.0/docs/api/overview-tree.html http://java.sun.com/j2se/1.5.0/docs/api/overview-tree.html

17 Understanding Layouts It is important to practice using the layouts such a flow layouts in order to understand how to present information attractively to the end user. Problem 8.5 in the text is a good exercise for this purpose.

18 Bibliography Jia, Xiaoping, Object Oriented Software Development Using Java. Addison Wesley, 2003 http://java.sun.com/reference/docs/index.html http://javadocs.org/


Download ppt "George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8."

Similar presentations


Ads by Google