Java Reference
In-Depth Information
If you executed the following statements, you would have two more String objects:
String empAddr = new String("1 Main St");
String empCSZ = new String("Albany, NY 11508");
Therefore, in the example, there are three unique String objects. Since an object is an instance of a class, this
means that there is a String class. The String class was created by the Java developers and “comes with Java.”
If you're a little confused, don't worry. We will cover instantiation and explain “what comes with Java” in greater
detail in later chapters. For now, just remember that there are a number of very useful classes that come with Java
and that these classes are used to build sophisticated Java applications quickly.
Constructors
When an object is created, Java runs the instantiated class's (i.e., the object's) constructor . A constructor is a
method with the same name as the class that does not return any value. For example, the constructor method for
the Employee class would be called Employee and could be defined as follows:
public Employee() { }
Notice that a return variable type is not specified. This is a rule for constructors: they cannot return any data.
The example is also considered a null (or default) constructor because it does not accept data (i.e., no parameters are
specified). However, a constructor can accept information. The following defines a constructor that accepts a String
object, creates a String variable called name and assigns the String object to name:
public Employee(String name) { }
As mentioned, when the Employee class is instantiated, the constructor method is automatically run. In the
above example, however, the constructor does nothing. Constructors are often used to initialize variables needed
by the class methods. For instance, the following constructor assigns the passed String object to the class variable
empName:
public Employee(String name) {
empName = name;
}
This is similar to the algebraic statements: A=1, B=A. In the Java example: name = String object,
empName = name. Therefore, name and empName contain the same value.
WebSphere
WebSphere is a group of IBM software products that includes all of the “development tools” that a programmer would
need to write, debug, and install Java applications. “Development tools” is a category of software that usually includes
a code editor, syntax checker, debugger, and many other useful programming utilities. In addition, WebSphere
includes software that can be installed on any computer to make that computer a Java application server.
There are many “versions” of WebSphere products (Express, Standard, Enterprise, etc.). These different versions
simply have different sets of tools. As of this writing, the Enterprise Editions have the most complete and powerful set
of Java development tools.
We will use the development tools provided by the Rational Application Developer (RAD). We will begin with
a tour of the RAD “client environment” and then demonstrate several of the “tools” used to create and run Java
applications. Later in the text, we will cover the WebSphere Application Server (WAS) software.
 
Search WWH ::




Custom Search