java - Computer Science 211 Data Structures Mount Holyoke...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science 211 Data Structures Mount Holyoke College Fall 2009 Topic Notes: Java and Object-Oriented Programming Review There are many ways to write a program to solve a particular problem correctly. The ways to write it so as to run efficiently are much more limited. In addition to efficiency and correctness, we will think about these implmentation goals for our programs: 1. Robustness produce correct output for all inputs - including erroneous input 2. Adaptability a program can evolve over time with new requirements 3. Reusability develop general-purpose code that may be used in multiple situations Programming Languages We will be programming in Java. There are many programming languages, and Java is just one example. We’ll take a look at a few others, just for fun. These are all “Hello, world” programs. See Example: /home/jteresco/shared/cs211/examples/Hello See http://www2.latech.edu/ acm/helloworld for many more examples. These languages all basically do the same thing, though some are much better than others at certain types of tasks. We choose to study data structures and advanced programming in Java because it is a modern, object-oriented language that runs on all modern computer systems. An appropriate choice of programming language makes it easier to write high-quality software. All computer languages are an abstraction to make it more convenient to get computers to do what we want them to do. We could write in 0’s and 1’s, but a variety of languages have been developed to facilitate the development of software. Most langauages, including C and C++ have compilers that translate source code into a executable program that runs on a particular machine. Java is different. All Java compilers translate to a particular virtual machine , which, in turn, runs on specific computers.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 211 Data Structures Fall 2009 This gives Java some advantages that we will discuss along the way. For now, we will look at programming in Java as a general-purpose modern object-oriented programming language. Java Review/Overview Back to our Hello, world example. Things to note in Hello.java: Everything in Java has to be in a class. More about classes in a minute. In C, there are no classes and in C++ there are classes, but you can write functions outside of any class in addition to class methods. Many of you have have seen only Java applets – this is a Java application . We will look primarily at applications here. Each class can have methods. An application has a class that must have a main method with the method signature: public static void main(String[] args) Exactly what is meant by all of these will become clear later, but basically this is where execution will start when we run this program. To execute this program using the command-line (text) interface to Java:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 02/15/2010.

Page1 / 8

java - Computer Science 211 Data Structures Mount Holyoke...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online