JCQ Java

Wednesday, September 06, 2006

Individual Objects

The one thing these Java objects have in common is this: their individuality.

In Java, the JVM (Java Virtual Machine) is responsible for creating objects -- and destroying them when they are no longer needed. Once an object is created, it behaves on its own -- like an individual.

To show you what this means, try:

java\demo\applets\MoleculeViewer\example3.html

There, you'll find more than one applet on a single webpage. Each applet runs the same Java program, but given different parameters. As a result, several objects (Java programs) are created, each displaying a different molecule. All these objects behave similarly (they come from the same program), yet their behaviour are individual (e.g. you can turn one molecule this way, the other molecule that way).

As you can see, that's are lot to learn about the simple "object". But it is fun, isn't it?
More examples of objects:

java\demo\applets\Clock\example1.html

* an object you can look but can't touch.


java\demo\applets\Animator\example3.html

* click to freeze, click again to unfreeze.
* an object you can only touch.


java\demo\applets\ArcTest\example1.html

* type the start angle (S) and end angle (E), then click "Draw", or "Fill" buttons.
* an object you can change by input.


java\demo\applets\SortDemo\example1.html

* click an applet to visually see how the sorting is done (the 2 color bars are swaps).
* start all the applets to see which sorting is fastest.
* similar objects (sort programs) but different behaviour (sorting methods).


The last one is an example of visualization of algorithm, using Java.

After all the data are sorted, you can click again to find out which algorithm is fastest on sorted data.

0 Comments:

Post a Comment

<< Home