CS 0401 Fall 2008 Handouts

 

ex1.java – Simple example showing basic Java program structure

 

ex2.java – Demonstration of some expressions and Java numeric types

 

ex3.java – Intro. to the Scanner class for input

 

ex4a.java ex4b.java – Using while loops to input data.  See comments for design approaches

 

            forexamples.java – Simple for loop examples from notes

 

ex4c.java ex4d.java – Using for loops to input data.  See comments for design approaches

 

ex5.java – Demonstration of the switch statement (+ money formatting output)

 

ex6.java – Using static methods in Java programs

 

ex7.java – Intro to (predefined) objects and instance methods

 

ex8.java – More on classes, objects and instance methods

 

ex9.java IntCircle.java – Simple example of writing a class and using it in a program

 

CD.java Song.java CDTest.java songs.txt – More complicated example with classes.  This demonstrates a lot of programming ideas – some of which we have not yet covered but will be covering soon.

 

ex10.java – Simple intro to Java arrays + text file reading with Scanner and writing with PrintWriter

 

ex10a.java – More on Java arrays – demonstrating sequential search and effect of reference variables

ex10b.java Scores.java – Compare to ex10a.java – same functionality but implemented in a more object-oriented way

 

ex11.java – Using 2-D arrays in Java

 

ex12.java SortInt.java – Demonstration of simple sorting in Java

 

BinarySearchDemo.java – Binary Search code from textbook

 

ex13a.java – “Hello Graphics” intro to Java GUIs

ex13b.java – Adding a button to a GUI / Demo of event handling

ex13c.java – Another button example

ex13d.java – Application with interacting components and private inner classes

 

Counters.java – Adding a panel to a window to subdivide it

Counters2.java – Extending JPanel to modularize the coding in a graphical application (compare to Counters.java)

 

ex14.java – Simple introduction to interfaces

 

ex15.java MyInteger.java – Wrappers, autoboxing and parsing numeric input

 

ex16.java – Some more wrapper class methods + string processing and command line arguments

 

ex17.java SuperClass.java SubClass.java – Introduction to inheritance

 

ex18.java RationalNumber.java MixedNumber.java MixedNumber2.java – Comparison of composition and inheritance in development of a new class

 

ex19.java – Demonstration of method overloading (ad-hoc polymorphism)

 

ex20.java – Demonstration of subclassing (true) polymorphism

 

ex21.java – Demonstration of abstract classes in Java (compare to ex20.java)

 

recursion.java – Simple recursion in Java

 

ex22.java SortAll.java – Using generic access to sort an array of any Comparable

ex22T.java SortAllT.java CDT.java – Using parameterized interface to improve type-checking on generics

 

ex23.java – Simple intro. to exceptions and exception propagation
MiniCalcTwo.java DoMathInt.java DoMathIntCheck.java – Exceptions in GUIs and exception subclasses