Академический Документы
Профессиональный Документы
Культура Документы
LOGO
IU-VNU-HCM
Contents
The Java Technology
The Java Platform
The "Hello World!" Application
Editors
IU-VNU-HCM
Company Logo
IU-VNU-HCM
Company Logo
Notepad: TextPad.
Netbeans: http://www.netbeans.org/index.html.
Eclipse: http://www.eclipse.org/.
IU-VNU-HCM
Company Logo
IU-VNU-HCM
IU-VNU-HCM
Company Logo
class HelloWorldApp
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}
IU-VNU-HCM
Compiler
The compiler is called javac. Youll need to include
the path to it, so type in:
IU-VNU-HCM
IU-VNU-HCM
Company Logo
IU-VNU-HCM
Notice
Each source code file defines a class
The name of the class it defines (First in our case)
must match the filename hence First.java
This is compiled to a bytecode file named
First.class
Java is case-sensitive (like C)
Classes should start with a capital letter.
Change First.java to first.java
Test with javac first.java
ERROR!
So the file must be called First.java and not
first.java
IU-VNU-HCM
Notice
Java is a pure object-oriented language.
No functions, no global variables
Unlike C++, which is C with objects
Java is designed to make it hard to write programs
which will crash
No pointers
Compiler will not compile doubtful code
Programmer must write code that catches exceptions
Run-time checks eg array bounds exceptions
Slower than C or C++ (not much), but less chance of
crash