Basic HTML version of Foils prepared June 5 99

Foil 49 Classes are used as program modules

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


1 Some classes, such as our hello application, have just one or more method that will be executed as a program. Only one instance of these classes is created (by the interpreter).
2 Other classes are used to structure data, such as the previous example. Another example might be to have a class to represent type Complex. It would have
  • variables to hold the real and imaginary parts of each instance
  • a method called Complex to initialize those variables on creation
  • methods called add, subtract, and so on to operate on each instance of the complex class.
3 A computational class could create several instances of the class Complex and use them with the methods for arithmetic.
4 Note an object carries a lot of "baggage" compared to a simple type. We are trying to get efficient lightweight classes into language

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Jun 5 1999