next up previous
Next:  Lecture 2

Lecture 1 Handouts


Announcements

The Faculty of Arts and Science wants me remind you that they have to have either a "registration card" or a U of T photo library card. To get an Arts and Science photo ID "registration card", students can come to Ramsay Wright room 429 either during the regular hours (MW 9-12, R 2-5) or during special evening hours:

5-7 p.m. on May 19, May 20, or July 14.

Because of overcrowding, in fairness to enrolled students, auditing is discouraged.

IF THE COURSE IS FULL AT THE END OF THE FIRST WEEK OF CLASSES, NO LATER ENROLMENTS WILL BE PERMITTED. That's a Faculty rule.


Readings


Humans versus Computers


Why use Java?


What is Java?


object oriented programming


Why Object Oriented?


Consider this java program

class HelloWorld {
 
  public static void main (String[] args) {

    System.out.println("Hello World!");

  }

}
There are three steps to create a Java program:

In a command line environment  (Unix or Dos) do this
 
# Step Comment
writing the code  Use an editor on HelloWorld.java. The file name must match the class name, HelloWorld.
compiling the code  javac HelloWorld.java 
running the code  java HelloWorld


Computer Session at the PC site.


Comments are to make code easier for people to understand Comments are ignored by the computer:

/* use this anywhere
    even splitting comments
    over multiple lines */
// use this for end of line comments only

// This is the Hello World program in Java
class HelloWorld {

  public static void main (String[] args) {

    /* Now let's print the line Hello World */
    System.out.println("Hello World!");

  } // main ends here

} // HelloWorld ends here

What is a class? Fields say what an object is
Methods say what an object does

class Point {

  double x;
  double y;
}
What is an object? Create objects with the new keyword followed by a constructor:
Point origin = new Point();
origin.x = 0.0;
origin.y = 0.0;
System.out.println("The origin is at (" +
origin.x + ", " + origin.y +")");



next up previous
Next: Lecture 2.
Craig MacDonald

Fri May 15 16:09:12 EDT 1998