import OtherClass;
(this goes before the class declaration)
javac PingPong.java Player.java ...)
main() method.
break exits the current loop (or switch).
continue exits the current repetition of the loop
(going back to the test, and, possibly, to another repetition of
the loop).
label: statement and then use
break label to break out of that statement.
For example
outer:
for (i = 0; i < N; ++i) {
inner:
for (j= 0; j < M; ++j) {
if (meetsCondition(i,j)) {
System.out.println(
"Found what we were looking for at (" +
i + "," + j + ")"
);
break outer;
} // if
} // inner for loop
// Here's where you go if you break out of the inner loop
} // outer for loop
// Here's where you go if you break out of the outer loop
continue can take a label, and returns to the
next iteration of the labeled loop.
DrawableObject class
and refine that to particular drawable objects, such as Circle
or Square.
extends keyword.
public class Circle extends DrawableObject {
// ...
}
DrawableObject obj = new Circle();
import OtherClass;
before your class definition.
Number agree to provide
a set of drawing routines.
Line objects, which
would most likely be a subclass of Polygon (or some
such) would also provide "mathematical" operations (so that you
could add, subtract, and compare lines).
interface instead of class
implements keyword,
as in
public class Complex implements Drawable {
// ...
} // Comples
Drawable d = new Complex();
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Mon Nov 10 08:56:52 1997.
This page generated on Mon Nov 10 10:13:12 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu