First
cup of JAVA
There are 3 steps to speak JAVA:
1. Type code
2. Compile code
3. Run code.
First step: type the following code to Wordpad or
any text editor you are familiar with. (cann't find your WordPad?
go to Start ->All programs->Accessories? Got it? Still not, ask
your mom/ Daddy help you)
class hello
{
public static void main(String[] args)
{
System.out.println("Hello! It is me, JAVA boy!");
}
}
Be cageful! Type the above code exactly as it is. I am very strict
with my language. I am case sensitive. class,Class means different
things to me!
Finished typing? All right! Save it as a file
named hello.java. .java is
my family name( those computer guru calls it extension name. Well,
what ever...) You may ask could I save it as bulabula.java? NO!!
you have to save it as hello.java. hello is
the file's first name and it is the class's name too( see the first
line in the code). The file's first name MUST match
its class name. MUST!
Second Step: compile hello.java. ( I assume you
installed JDK5.0. Please
see Appendix for detail installation. If you are a parent, do it
for your kids. If you are a kid, take an adventure and install it
by yourself. It is very easy to install.) Now, open a command
prompt. (Start->All programs->Accessories->Command prompt).
Type: javac hello.java
If JDK was installed in a right way, you won't see any error.
Third Step: run hello program. Still in that command
prompt,
type: java hello
You should see: Hello! It is me, JAVA
boy!
Congratulations! You are speaking JAVA!
|