Phase 1: Creating A Program: Editor Program Editor Source Code
Phase 1: Creating A Program: Editor Program Editor Source Code
Object Oriented: - In Java, everything is an Object. Java can be easily extended since it is
based on the Object model.
Java Is a Secure Language: - With Java's secure feature, it enables to develop virus-free
systems.
Portable: - Due to its Byte code is in Bytes, java program takes very less memory on hard
disk and therefore java technology is Portable also.
Phase 1 consists of editing a file with an editor program (normally known simply as an
editor).
You type a Java program (typically referred to as source code) using the editors (vi and
emacs for Linux and notepad for windows) make any necessary corrections and save the
program on a secondary storage device, such as your hard drive.
A file name ending with the .java extension indicates that the file contains Java source
code.
Integrated Development Environments(IDEs) provide tools that support the software
development process, including editors for writing and editing programs and debuggers for
locating logic errors.
Popular IDEs include Eclipse (www.eclipse.org), NetBeans (www.netbeans.org), JBuilder
(www.borland.com), JCreator (www.jcreator.com), BlueJ (www.blueJ.org), jGRASP
(www.jgrasp.org) and jEdit (www.jedit.org).
Phase 2: Compiling a Java Program into Bytecodes
In Phase 2, the programmer uses the command javac (the Java compiler) to compile a
Program.
If the program compiles, the compiler produces a .class file called className.class that
contains the compiled version of the program.
The Java compiler translates Java source code into bytecodes that represent the tasks to
execute in the execution phase (Phase 5).
Bytecodes are executed by the Java Virtual Machine (JVM)—a part of the JDK and
the foundation of the Java platform.
A Virtual Machine (VM) is a software application that simulates a computer, but
hides the under-lying operating system and hardware from the programs that interact
with the VM.
If the same VM is implemented on many computer platforms, applications that it
executes can be used on all those platforms. The JVM is one of the most widely used
virtual machines.
Unlike machine language, which is dependent on specific computer hardware,
bytecodes are platform-independent instructions—they are not dependent on a
particular hardware platform.
So Java’s bytecodes are portable—that is, the same bytecodes can execute on any
platform containing a JVM that understands the version of Java in which the bytecodes
were compiled.
The JVM is invoked by the java command. For example, to execute a Java application
called Welcome, you would type the command java Welcome
Arithmetic operators
Most programs perform arithmetic calculations.
The arithmetic operators are binary operators because they each operate on two operands.
Arithmetic expressions in Java must be written in straight-line form to facilitate entering
programs into the computer.
All constants, variables and operators appear in a straight line (e.g. a / b).
Figure 2: Arithmetic operators
Java applies the operators in arithmetic expressions in a precise sequence determined by the
following rules of operator precedence:
1. Multiplication, division and remainder operations are applied first. If an expression
contains several such operations, the operators are applied from left to right.
Multiplication, division and remainder operators have the same level of precedence.
2. Addition and subtraction operations are applied next. If an expression contains several
such operations, the operators are applied from left to right. Addition and subtraction
operators have the same level of precedence.
Array
Arrays are data structures consisting of related data items of the same type.
Arrays are fixed-length entities—they remain the same length once they are created, although an
array variable may be reassigned such that it refers to a new array of a different length.
An array is a group of variables (called elements or components) containing values that all have
the same type.