Professor Kit Romano's Web Site

 



Site Index

About Me

Welcome
Definition of Program
Variable Types
Understanding Memory
Declaring Variables
Simple Commands
Concatenation and Strings
Sleep-Threads-Try Catch
Campus Scenes
Pictures
Java simplified
Application Shell Styles
Reading Data From File
Overview of Applets
Excellent Graphics Applet
Online Reference
Nested if statements
Arrays
Sorting Arrays
Using Strings
Functions
Top 20 Replies 
First program 211
Important Class Example
JAVA in SDK Environment
Understanding OOP
OOP simple example
Recursion example
Example of Inheritance
     and use of JTextArea



*** Web Related **********
Build Student Web Page ?
What is FTP
Download WS ftp95
Download Java Plug In
Applets from jbuilder to sdk
Practice Problems

 

Programming Examples

 

 

                                                

 

Application Shell Styles

Style 1     
// simplest one to start with

package untitled1;

import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1 
{
  public static void main(String args[])
       {
        DECLARE ALL VARIABLES
        WRITE ALL JAVA COMMANDS
        System.exit(0); 
       } 
}

Style 2
// introduction to using functions also
// includes try - catch blocks to give you an
// idea of the logic flow for your first program
// Pay attention to the brackets and the order
// I used two arrays as an example but you will
// have more


package untitled1;

import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1 
{
   public static void main(String args[])
    {
         int scores[][] = new int[10][5];
         float avg[] = new float[10];
                 
         DECLARE VARIABLES or arrays only known in MAIN
         MUST be passed to functions if the functions
         are to access them
         try
         {
           // open files
           do
             {
               // read record
               // break it into logical pieces
               // store it in arrays
              }  while (  etc )
                call function1   ( scores, avg );
                // sort all data based on avg arfray
                call function2  (   etc  ) // printing
         }    
         catch
          {
           // output error condition
          }        
         System.exit(0);
    }   // end main method


    function1  ( int scores[][], float avg[] )  
    {
       code to comput averages etc
    } 
    function2  // all arrays must be passed
    {
       code to do output
    }
   
}  // end class

Style 3
// creating an oblect of a class and
// placing all code in the constructor

package untitled1;

import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1 
{
     public Application1()  // construstor method for class
       {
          DECLARE ALL VARIABLES
          WRITE SOURCE CODE
       }

     public static void main(String args[])
       {
         Application1 app = new Application1();  // create object
         System.exit(0);
       } 

}

Style 4

// best style for OOP using functions (methods )  
// advanced 314 students


package untitled1;

import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1 
{
   DECLARE GLOBAL VARIABLES  calles INSTANCE VARIABLES     

      public Application1()  // construstor method for class
       {
          Declare all arrays etc
          start the logic of your program
          and call the methods (functions) below when needed 

      
       }
      public method1
       {
          code
       } 
      public method2
       {
          code
       } 
      public method3
       {
          code
       }
     
ETC 

     public static void main(String args[])
       {
         Application1 app = new Application1();  // create object
         System.exit(0);
       } 

}