Home : Course Map : Chapter 1 : Java :
Starter Codes
JavaTech
Course Map
Chapter 1
Introduction
History
What is Java?
Versions
Java 5.0
Features

Java Process
Tools
Documentation
Compatibility
Getting Started
Simple Applet
Simple Application
Starters
Exercises

    Supplements
Interpret/Compile

Making WebPages
Plug-in
Java 5.0 Features
The JVM
Advanced JVMs
Alt. Compilers
Alt. JVMs
Java Deployment

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

To help with exercises and to provide a quick way to test code snippets in the following chapters, we provide a set of prepackaged programs with which you can begin to write a program rather than starting from scratch each time.

These starter programs (our terminology), like the ones shown below, can run by themselves but accomplish very little. Instead, you insert example snippets or your own code to make them do something interesting. The starters allow you to concentrate on the particular topic of interest rather than taking the time to writing a whole program

For example, we show here the application program StartApp1:

StartApp1.java

public class Start_App1
{
  public static void main (String args[])
  {
    // Put code between this line
    //----------------------------

    


    //----------------------------
    // and this line.
  }
}






Insert the example codes or your exercise code between these lines.

We also provide starters for applets. At this early stage, however, before we discuss Java graphics, we will just send output to the browser's Java console and only paint a brief text message in the browser window .

StartApplet1.java

public class Start_Applet1 extends
             java.applet.Applet
{
 
 
 
 public void init ()
 {




    // Put code between this line
    //----------------------------

    


    //----------------------------
    // and this line.

 }
 
 // Paint text in the applet window.
 public void paint (java.awt.Graphics g)
 {
   g.drawString ("Start_Applet1",10,20);
 }
}

We will learn later
how user applets
inherit the Applet
class.
 
 
The browser always calls init()to let the applet do initialization tasks.
 
 

Insert the example codes or your exercise program between these lines.
 



Paint a simple message in the applet window.

The Codes List describes each of the starter applications and applets.

We recommend that you give each example program a unique class name, e.g. starting from StartApp1.java create class XApp1 in file XApp1.java. In the comments at the top of our classes, we will indicate what starter we used.

References & Web Resources

Latest update: Oct. 14, 2004

            Tech
Java in Science
    & Engineering
Benefits
Shortcomings
RealWorld Examples

           Physics
Java in Physics
SimulationTypes
Simulate&Analyze
Sim. in Experiments
  Demo 1: Event
  Demo 2: Continuous
  Demo 3: Static

Learn by Coding
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.