Packages

Treescript programs are organized into packages that contain the source code declarations of Treescript classes and interfaces. Packages are identified by the package statement. It is the first statement in a source code file:

 

package package-name

 

If a package statement is omitted, the classes and interfaces declared within the package are put into the default no-name package. The package name and the CLASSPATH are used to find a class. Only one class or interface may be declared as public for a given source code file (compilation unit). For example, you can define classes X and Y and interface Z within a compilation unit, but only one of these three can be declared public. The name of the compilation unit must be the name of the public class or interface followed by the .TS extension.

 

The import Statement

The import statement is used to reference classes and interfaces that are declared in other packages. There are three forms of the import statement:

·      import ( package-name class-name )

·      import ( package-name interface-name )

·      import ( package-name * )

The first and second forms allow the identified classes and interfaces to be referenced without specifying the name of their package. The third form allows all classes and interfaces in the specified package to be referenced without specifying the name of their package.