Java

Not part of Unix, but also for Java I need a place where I can refresh my memory. This page describes some conceptual information. Links to more detailed information will appear when available.

Sun Microsystems invented Java and has the original documentation, a tutorial and a complete API overview. Very useful are also the Code Conventions.

Until now I only write applets, so this works for applets, applets is java to run in a web-browser. Applet-Java does not really differ from non-applet-Java. There is also java-script, Java-script is intended for intelligence within a web-page like for buttons.
Java programs can run on any computer with the Java Runtime Environment (JRE) which provides the Java Virtual Machine (JVM). Java programs can be stand-alone applications, applets (running on the client in a browser), servlets (running on the server only using the clients display (web-browser)).

Java is an Object Oriented language. It represents the world as instances of classes. Classes have certain quality’s (variables) and certain abilities (methods).

class
public class <classname>

A class defines an object. A class has variables and methods
(functions)

Example:
Public class suitcase {
Variables:
String color, weight; // (variables)

Methods:
public lift {}
public open {}
public close {}
}

methods
What you can do with a class.

An applet automatically calls the methods init,
start, run in this order when it is loaded.

A browser calls paint to refresh the
applet-window, stop to stop the applet, destroy to remove the applet from memory.

An applet must call repaint to call
paint.

Constructor
A constructor is a method defining the variables of a new instance of a class. The constructor is recognized by having the same name as the class. A class is instantiated like:
suitcase mine = new suitcase (blue, 15)

Example:
Public class suitcase {
private String color; // (variables)
private int weight;

public suitcase(String col, int we) {
color = col;
weight = we;

}

public lift {}
public open {}
public close {}
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.