CIS 260 (Java II) Demonstration Programs

Input and output

  1. IOapalooza1.java: keyboard as BufferedReader
  2. IOapalooza2.java: keyboard using Scanner class
  3. IOapalooza3.java: I/O using JOptionPanes
  4. IOapalooza4.java: using a complex JOptionPane
  5. IOapalooza5.java: using a full-blown GUI
  6. IOapalooza6.java: making the GUI into its own object
  7. IOapalooza7.java: DecimalFormat class
  8. IOapalooza8.java: printf method, Formatter class, format method
  9. Scanner1.java: Scanner class and static import
  10. TestPrintf.java: Formatter class and printf() method

Text and binary file I/O

  1. SimpleFileIO.java: reads and writes text files
  2. int1to100.txt: used as input file for SimpleFileIO.java
  3. Course.java: a basic class use with the UseCourse programs
  4. FileInfo.java: demonstrates File class
  5. UseCourse.java: sequential file output using Formatter class
  6. UseCourse2.java: variation of UseCourse.java
  7. UseCourse3.java: reads data files created by UseCourse.java and UseCourse2.java
  8. SerialTest.java: reads/writes objects from/to files using Serializable interface
  9. RandomTest.java: demonstrates random access file techniques
  10. RandomTest2.java: variation of RandomTest.java that converts Unicode characters to byte values to save space
  11. Binary01.java: writes and then reads binary data in a file
  12. Binary02.java: writes and then reads binary data in a file using a class for the record to make life easier
  13. Binary03.java: binary file access using seek (random access)
  14. ReadBinaryNIO2.java: reading a binary file using NIO2 techniques
  15. CreateData02.java: program used to create binary data file from a text file with population data

Layout managers and GUIs

  1. TestCardLayout1.java: CardLayout demonstration with previous and next buttons
  2. TestCardLayout2.java: CardLayout demonstration with direct access buttons
  3. TestGridBagLayout1.java: basic GridBagLayout
  4. TestGridBagLayout2.java: GridBagLayout using insets
  5. TestGridBagLayout3.java: GridBagLayout using gridwidth and gridheight
  6. TestGridBagLayout4.java: GridBagLayout using fill
  7. TestGridBagLayout5.java: GridBagLayout using weightx and weighty
  8. TestGridBagLayout6.java: GridBagLayout with no fill and larger frame size
  9. TestGridBagLayout7.java: GridBagLayout using anchor points
  10. TestGridBagLayout8.java: GridBagLayout using ipadx and ipady
  11. TestDesktop.java: demonstration of JDesktopPane holding JInternalFrames
  12. TestTabbedPane.java: demonstration of a tabbed interface using JTabbedPane
  13. TestViewer.java: a work in progress at the school demonstrating how to launch an external application from a Java application
  14. TestToggleButtons.java: checkboxes and radio buttons
  15. TestListWidgets.java: JList and JComboBox
  16. GUI demonstration (Binary calculator)
  17. Ed.java: text editor demonstrating GUI components

Collections: Vector, ArrayList, HashMap, LinkedList

  1. TestVector.java: demonstrates the Vector class
  2. Coll1.java: demonstrates the Vector class
  3. Coll2.java: demonstrates the HashMap class
  4. Coll3.java: demonstrates how to use an Iterator
  5. TestArrayList.java: demonstrates an ArrayList
  6. TestLinkedList.java: demonstrates a LinkedList
  7. TestHashtable.java: demonstrates a HashTable
  8. TArray0.java: interactive unordered array manipulator
  9. TArray1.java: interactive ordered array manipulator

Arrays (includes collections and iterators)

  1. TestArrays.java: demo of Arrays and Collections
  2. TestSync.java: demonstrates how List objects can change underlying array
  3. TestEnumeration1.java: creating and using an Enumeration object
  4. TestIterator1.java: using an Iterator
  5. TestIterator2.java: using a ListIterator
  6. Array0.java: using "String[] args" to get command line arguments (CIS 160)
  7. Array1.java: basic array usage; passing arrays to methods (CIS 160)
  8. Array2.java: reading array data from a file; dealing with partially filled arrays (CIS 160)
  9. Array3.java: processing file data before saving it in an array; using methods to process data (CIS 160)
  10. Array4.java: reading parallel arrays from file (CIS 160)
  11. Array5.java: linear searching of arrays; using parallel arrays (CIS 160)
  12. Array6.java: sorting parallel arrays (CIS 160)
  13. Array7.java: using arrays of objects (CIS 160)
  14. Array8.java: using the Arrays class to sort an array of objects
    array8data.txt: data file for Array8.java (make sure after transferring data file that there is no blank line after last record and theat each record is on its own line) (CIS 160)
  15. Array9.java: reading an indeterminate number of items into an array with error checking (CIS 160)
  16. SortArray1.java: use Array class to sort an array of Integer objects
  17. SortArray2.java: use Array class to sort an array of ints
  18. SortArray3.java: use Array class and a custom Comparator to do a customized sort of an array of objects
  19. MultiDim1.java: multidimensional array demonstration

Class, interface, inheritance, composition

  1. Course.java: demonstrates a basic class
  2. TestClass.java: demonstrates some basic class concepts
  3. Drawable.java: an interface that contracts for a draw method
  4. Point.java: a simple class that specifies a point on a 2D grid
  5. Shape.java: an abstract class the implements Drawable, and contains a Point
  6. Circle.java: a subclass of Shape that implements Shape's abstract methods
  7. Rectangle.java: a subclass of Shape that implements Shape's abstract methods
  8. TestShapes.java: an Applet that tests out the classes and interface used for this demonstration
  9. TestShapes2.java: the JApplet version of TestShapes.java

Recursion

  1. Recurse.java: various recursion algorithms (CIS 160)
  2. Recurse.java: demonstration of recursion
  3. RecursiveSearch.java: recursion isn't always a good thing

Searching, and sorting

  1. Search.java: linear and binary searching (CIS 160)
  2. RecursiveSearch.java: recursion isn't always a good thing
  3. Sort.java: various sorting algorithms (CIS 160)
  4. Sort2.java: demonstration of sorting techniques with timings
  5. DemoHeapSort.java: demonstration of heap sort
  6. DemoHeapSortG.java: demonstration of heap sort using generics
  7. DemoHeapSortG2.java: demonstration of heap sort using generics (with a demonstration class)
  8. DemoQuickSort.java: demonstration of recursive quicksort using generics
  9. DemoQuickSort2.java: demonstration of iterative quicksort using generics
  10. RevisedQuicksort.java: a better Quicksort algorithm to base changes on [obsolete]
  11. Sort.java: class that implements a quicksort on an array of objects [obsolete]
  12. TestSort.java: test program for Sort class [obsolete]
  13. TestHeap.java: demonstration of a heap sort [obsolete]

Variable argument lists, autoboxing, assertions, JavaDoc

  1. VarArgs1.java: using variable argument lists
  2. VarArgs2.java: using variable argument lists
  3. VarArgs3.java: using variable argument lists
  4. AutoBox1.java: demonstrates Java 1.5's new autoboxing feature
  5. TestAssert1.java: default assertion
  6. TestAssert2.java: assertion with custom message
  7. TestJavadoc.java: demo of automated Java documentation feature

Multithreading demonstrations

  1. TThread0.java: the problem
  2. TThread1.java: sleep doesn't solve the problem; it just slows everything down
  3. TThread2.java: creating threads
  4. TThread3.java: using threads
  5. TThread4.java: the Runnable interface
  6. TThread5.java: shared resource problems I
  7. TThread6.java: shared resource problems II (reorganized)
  8. TThread7.java: synchronized methods
  9. TThread8.java: synchronized code blocks
  10. TThread9.java: the wait() method
  11. TThreadA.java: the notify method()
  12. TThread5b.java: new finer grained locking available in Java 1.5
  13. HorseRace.java: a simulation with numerous threads

Strings and Regular expressions

  1. RegEx1.java: basic regex demo
  2. RegEx2.java: interactive regex demo
    2cities.html: text file for RegEx2 program
  3. RegEx3.java: another regex demo
  4. Tokenize.java: demonstrates an easy way to tokenize a string
  5. FindLinks.java: finds links in web pages online
  6. Tokenize.java: demonstrates StringTokenizer (no regex)
  7. dict.txt: dictionary of words used with Chapter16a and Chapter16b programs (from SIL International's website)
  8. Chapter16a.java: uses String.matches and regex
  9. Chapter16b.java: Files.readAllLines, and the String methods startsWith, endsWith, and indexOf
  10. Chapter16c.java: uses several static Character class methods
  11. Chapter16d.java: demonstrates the StringBuilder class
  12. Chapter16e.java: two ways to tokenize a String
  13. Chapter16f.java: demonstrates String.replace with regex

Data structures

  1. TStack0.java: interactive stack manipulator
  2. TQueue0.java: interactive queue manipulator
  3. TQueue1.java: interactive circular queue manipulator
  4. LList.java: implementation of a linked list (TestLList.java: test driver for LList class)
  5. LinkedList.java: implementation of a linked list using generics (TestLL.java: test driver for LinkedList class)
  6. GTestLinkedList.java: linked list class using generics
  7. MyStack.java (simple stack class) · TMyStack.java (driver)
  8. MyGStack.java (generic stack class) · TMyGStack1.java (driver 1) · TMyGStack2.java (driver 2)
  9. MyGQueue.java (generic queue class) · TMyGQueue1.java (driver 1) · TMyGQueue2.java (driver 2)
  10. MyGDQueue.java (double ended queue) · TMyGDQueue1.java (test driver)
  11. GTestStack.java: stack class using generics
  12. GTestQueue.java: queue class using generics
  13. BST.java: implementation of a binary tree class using generics
  14. Countable.java: Countable interface for use with BST.java
  15. TestBST.java: Test driver for BST.java
  16. TestGraph.java: graph code demonstration

Various topics

  1. Deprecated1.java: using deprecated methods (won't compile)
  2. Deprecated2.java: deprecated methods replaced (from Deprecated1.java)
  3. FullSpec.java: ommitting import statement and using full class specification
  4. ImportStatic.java: an example of using a static import
  5. TestForIn.java: deonstration of new "for/in" loop
  6. Banner.txt: demonstrates how to create a package
  7. NewPage.java: applet which loads new web page NewPage.html
  8. NewPage2.java: applet which loads new web page - HTML tag specifies that code is stored in an archive (jar) file NewPage2.html
  9. TestPlugin.java: Java Plugin test TestPlugin.html
  10. TestParam.java: getting parameters from web page TestParameter.html
  11. Brutus.java: brute force approach to 4-queens problem