SE450: Basics: Constructors/Methods/Fields [28/63] Previous pageContentsNext page

Object classes have three kinds of members:

file:Main3.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
package basics.objectclass;
// A static class
public class Main3 {
  private Main3() {}
  static public void main (String[] args) {
    //stdlib.Trace.graphvizShowSteps (true); stdlib.Trace.run ();
    Circle3[] list = new Circle3[3];
    for (int i = 0; i < list.length; i++)
      list[i] = new Circle3 (i*10);
    for (Circle3 c : list)
      System.out.println(c);
  }
}
// An object class
final class Circle3 extends Object {
  int radius;
  public Circle3(int radius) { this.radius = radius; }
  public String toString() { return "Circle(" + radius + ")"; }
}
trace-basics-objectclass-005-Circle3_17 trace-basics-objectclass-006-Main3_main_9 trace-basics-objectclass-007-Main3_main_8 trace-basics-objectclass-015-Main3_main_8 trace-basics-objectclass-018-Circle3_toString_18 trace-basics-objectclass-019-Main3_main_10

Previous pageContentsNext page