Classes
An application is a collection of classes. Each class is represented by a class file.
class: Clock
The class may inherit the properties of a super class.
class: Clock extends Applet
If no super class is indicated, the class inherits from java.lang.Object.
The class may also implement one or more interfaces.
class: Clock extends Applet implements Runnable
The class file has the same name as the class within the restrictions of MS DOS.
A HolonJ module corresponds to a class. The name of the module is free, it can be different from the name of the class.
interface: identifier
The methods in an interface are abstract. HolonJ marks the methods of the interface as abstract by default.
An object is an instance of a class. The object is created by a method with the command new applied to a global or local class variable.
Clock myClock
... new myClock ( -- ) ...
A class can have several constructors. The actual constructor is selected by its stack signature. The empty stacksignature may also be written ().
The symbol this refers to (an object of) the current class.
The symbol super is not available in HolonJ. Methods in the super class are called like other methods. Example:
class: MyClass extends Frame
importmethod: Frame.toString
Frame toString ( -- string ): myclass.toString ( -- string )
Frame.toString " mytext" "+ ;
An inner class is just another class in HolonJ. It is defined separately from the enclosing class and has a public name.
HolonJ is quite happy without a package. The classfiles of the application are then stored in the directory of HolonJ. If you define a package, say
package: com.holon.project
the classfiles are stored in the subdirectory com\holon\project\. HolonJ does not create the directories, please build them separately.
1998-2013 Wolf Wejgaard