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:
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 !
A JavaClass defines a set of characteristics.
SayHellois the name of our class.
public static voidmain(...)
main(...)When we invoke this class, java will run this program.
voidMeans that our main(...) method won't give anything back to any other program that might have brought SayHello to life.
staticThe only thing we want our class to do can be done without creating any instances.
publicWe 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.
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's Home Page