Java by Ahmed Hamdy Eissa




Java

Java is more than a programming language. It is much like C++ language. Java knocked down the walls between different various of personal computers, letting any program run without conversion on any kind of machine. It does things other languages does, but it does it better.

1) An Editor Program: Lets you create files .java of Java source code.

2) A compiler Program: Translate source code into .class files of computer-readable bytecodes.
Java handle errors better than C++. Example:
int myNumber;
myNumber = 2.3,
Java compiler will not truncate and will not round the number, it will send an error message.

3) A Java Interpreter program: Runs those bytecodes to produce the desired behavior.

There are 4 ways to run your Java program:
1. In Text Mode Window: such as DOS Window under Window 95. Those Java programs are called console programs.
2. With the Graphical enhancements that users expect to see on a Web page. A program in that mode called an applet viewer or called stand-alone application, and it is harder to write.
3. Embed your Java program in a Web page. Such a page may contain several Java programs.
4. In the Debugger: your program is contained by a middle layer of software. The debugger lets you examine the values of different pieces of data at various stages of the program's operation. The program runs slower in the debugger and it take up more disk space and use more memory.


Your First Java Program: Hello !
Class
SayHello
{
public static void main(String args[ ])
{ System.out.println("
Hello ");
}
}

A Java Class defines a set of characteristics.

SayHello is the name of our class.

public static void main(...)

main(...) When we invoke this class, java will run this program.

void Means that our main(...) method won't give anything back to any other program that might have brought SayHello to life.
SayHello will arise, put its output on the screen, and die. Only the user who's watching the screen will see Hello on the screen.

static The only thing we want our class to do can be done without creating any instances.

public We aren't trying to hide this piece of program from any other programs.

String args[ ] String is a class. String lets us do operations on string variables. Strings are usually sequences of letters.
The
String args[ ] , means that SayHello class will come to life with a little bundle of data (arguments) inside it. Programmers call it an array.

System.out.println(" Hello "); Displays whatever's inside the parentheses as a line of output to Java console "Hello".

println(" Hello "); Means Java will automatically start a new output line after putting out the thing we asked to see.


Ahmed Hamdy Eissa's E-mail Address


Go to top of page

Ahmed's Home Page