INTRODUCTION TO JAVA

WEEK 1

Introduction to Java

Programming Process with Problem analysis-Algorithm- Coding and Execution Cycle

  1. Analyze the problem and outline the problem and its solution requirements

  2. Design an algorithm to solve the problem

  3. Implement the algorithm in a programming language, such as Java (create a program.)

  4. Verify that the algorithm works. (compile -run- test)

  5. Maintain the program by using and improving it , and modifying it if the problem domain changes.

Processing of a Java Program

  1. Use a text editor create a  program (source code.)

  2. Compile the program - translate the program into the equivalent bytecode and check for syntax errors.

  3. If no error is found, the compiler translates the program into bytecode. otherwise, go to step 1 edit the program.
    to fix the error.

  4. The loader connects the bytecode for classes used in the program with the program's bytecode. The loader also loaded
    the complete program's bytecode into main memory.

  5. The interpreter translates each bytecode instruction into your computer's machine language, and then executes it.

The basic structure of a Java console application

public class test
{
     public static void main (string[] args)
    {
              Write coding       
     }

}

The file name must be identical to the class name.
In this case the file name you type is  test.
The actual file name is test.java. All java files has an extension of java.

A simple Java program


public class Test
{ //This program displays a message
  public static void main(String[] args)
 {
      System.out.println("I love Java!!!");

 }//end main
}//end class

Program analysis

From the source code to running the program 

EditoràSource code àCompileràClass files (byte code) machine languageàInterpreter à Output (Running Program)

Compiler:  translates a programs written in a high-level language into machine code and identify the syntax errors.
Java compiler used in the class is called Dr. Java

Edit , Compile and Test Process

  1. Create or edit the program

  2. Compile the program. If the program has syntax error(s), go to step 2 to edit and fix the error(s).

  3. Run, execute or test the program . If the program has logical error(s) or run-time errors, go to step1.