Lab 7
Page 1


Lab 7: Intro to Java and Sorting

By the end of this lab, you will be able to:


While typing a paper into your favorite word processor, or perhaps while playing the hottest new computer game, you might have at some point wondered: how do people create these great programs? The answer, of course, is with programming languages. Programming languages provide a way to express computer algorithms in a form that is both human-palatable yet easily translated into a computer's machine language.

In class, we have studied machine language and discussed the use of assembly language as a slightly more human-friendly alternative to machine language. Even assembly language is a far cry from the pseudocode that we used to write algorithms -- assembly language is cumbersome to write and hard to understand. In addition, assembly language programs are not readily portable, which means that they cannot be easily converted to a working program on a different kind of computer. (We'll talk more about portability later on).

To solve these two problems (comprehensibility and portability), high-level programming languages have been developed. Such languages contain a syntax closer to that of spoken language, and they can be easily translated into a working program on any computer, provided that a translator program exists for that computer. Some examples of high-level languages are Pascal, FORTRAN, C, C++, and Java.

There are two largely overlapping components of the programming process -- the algorithm and the implementation. The algorithm is the plan that the program will follow to accomplish its goal, while the implementation is the specific way which the programmer uses tools to accomplish that plan. Usually, we describe an algorithm in either plain human language or in some kind of pseudocode describing the steps to be taken; implementing the algorithm then consists of translating those ideas into a computer language. In class we have discussed sorting algorithms. In this lab, we will further explore sorting algorithms and how to implement them in Java.

Java is a modern, object-oriented, high-level programming language that was designed particularly to be used with the Web. We do not expect you to become full-fledged Java programmers. Much of each Java program has been written for you, and you don't need to know how many of the parts work (there are comments saying what they do). However, you will need to write enough Java to express a sorting algorithm. This will give you an understanding of what these programs really look like and what is involved in programming, i.e. what is involved in taking an algorithm and turning it into a precise program implementing that algorithm.

For further information on Java, follow this link.


Page 1: Introduction (this page)
Page 2: Java Programming
Page 3: Editing, Compiling and Running Java Applets
Page 4: Selection Sort
Page 5: Further Exploration of Sorting
Page 6: Finishing up and Shutting Down