UNC-CH COMP 210

Learning Java Programming



These items are video links explaining code that downloadable. Down load the code, follow along with the videos in your IDE

Download the code for following vids (zip file)

Power Point information on Stack, Heap, Classes, Objects


Encapsulation


Abstraction

Download code for Interfaces (zip file)
Download code for Interface explanation using A2 (zip file)
Download code for using HashMap in Java (zip file)

HashMap is in the Java Collections library, and for Assignment 5 and 6 you may use data structures from the collections (such as HashMap, Queue, Stack, PriorityQueue, etc.)

BTW, you should be able to take these example Java programs, and user TreeMap instead of HashMap, since both are Maps. However, for large data, TreeMap is not as efficient.


Download code for using Stack, Queue, Deque, PriorityQueue in Java (zip file)

Stack, Queue, Deque, and PriorityQueue are all in the Java Collections library, and for Assignment 5 and 6 you may use data structures from the collections. Here are examples of how to do this.

Note that PriorityQueue Ex 3 and 4 show how to define a comparator function when you need a Priority Queue where the items in the Queue are not basic Java types (like String and int) where we have a built in "<" ordering function. A comparator function will take two items of the types in the Queue and return a value telling is the first item is less_than, greater_than, or equal_to the second item. In Ex4 we created something similar to what you need for Dijkstra's algorithm (A6). The PriorityQueue contains pairs (int,String) where the String is the name of a node, and the int is the priority (the distance we currently know for the path from start to the node named in the pair). Once we get a pair out of the PriorityQueue we take the name component, hash it and get the actual object with that node name.