Points

What is a class?

Fields say what an object is

Methods say what an object does

class TwoDPoint {

  double x;
  double y;
  
}
To compile this class, put it in a file called TwoDPoint.java and type:

% javac TwoDPoint.java
What does this produce?

Is this a complete program? Can you run it?

Other Examples:


Previous | Next | Top
Last Modified August 31, 1998
Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu