Java Basics


Before you can even consider tackling the interesting and challenging task of developing Java applications, you must understand the basics of the Java language. This section discusses the following:

  • Creating Java source files

  • Compiling source files into class objects

  • Running a Java application

All the examples in this section use the Remote System Explorer (RSE) component of WDSc for iSeries. Drill into the IFS and the Root File System. Create a new folder name i5Primer, then create a new file within that folder named Vehicle.java. Figure 26.3 shows the code for Vehicle.java.

image from book
Figure 26.3: Source code for Vehicle Java Class.

Lines of code that begin with // are considered comments.

  • The code class Vehicle { identifies the beginning of the source that describes the class named "Vehicle." The first open brace ({) marks the beginning of the code for Vehicle.

  • The code public Vehicle() { begins a constructor method for the class. A constructor method is a section of code that creates a new instance of the class. It is possible to have multiple constructors, each one having a different set of arguments (parameters).

  • The System.out.println("Vehicle: Ford Explorer"); prints the text "Vehicle: Ford Explorer." Notice that the line of code ends with a semicolon. Most lines of code within the class will end in semicolons.

The first close brace (}) ends the constructor method, and the second close brace ends the class. All classes will resemble this basic format. Examples throughout the rest of this chapter illustrate increasingly complex techniques.



IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 245

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net