Java Reference
In-Depth Information
Step 1
Use editor to
create/edit source file
output
Hello.java
Step 2
Submit source file
to Java compiler
failure
success
output
Hello.class
Step 3
Execute Java
class file
Figure 1.1
Creation and execution of a Java program
To keep things simple, most of the sample programs in this topic involve con-
sole interaction. Keeping the interaction simple will allow you to focus your atten-
tion and effort on other aspects of programming. For those who are interested,
Chapter 14 describes how to write programs that use more modern graphical user
interfaces.
1.2 And Now—Java
It's time to look at a complete Java program. In the Java programming language,
nothing can exist outside of a class .
Class
A unit of code that is the basic building block of Java programs.
The notion of a class is much richer than this, as you'll see when we get to
Chapter 8, but for now all you need to know is that each of your Java programs will
be stored in a class.
It is a tradition in computer science that when you describe a new programming lan-
guage, you should start with a program that produces a single line of output with the
words, “Hello, world!” The “hello world” tradition has been broken by many authors
of Java books because the program turns out not to be as short and simple when it is
written in Java as when it is written in other languages, but we'll use it here anyway.
 
Search WWH ::




Custom Search