Introduction to Java                   P. Komisar
                                                                                                                                             18 /7/2001


"Java is a general-purpose, concurrent, class-based, object-oriented language.
 It is designed to be simple enough that many programmers can achieve fluency
 in the language. Java is related to C and C++ but is organized rather differently,
 with a number of aspects of C and C++ omitted and a few ideas from other
 languages  included. Java is intended to be a production language, not a research
 language, and so, as C. A. R. Hoare suggested in his classic paper on language
 design, the design of Java has avoided including new and untested features."

the first paragraph of 'The Java Language Specificaton' -Gosling, Joy & Steeles


First Context

Before beginning to learn the Java programming language, it is helpful to view briefly
the historical context in which Java was created in. Most traditional computer texts
start in this fashion. There are a number of interesting facts that go with this story so
we will follow suite and start the course with a version of how computers came to be.
 

A Brief History of Computing

In learning Java, we are tuning in to an ongoing process of man-machine interaction that
has been an intensely pursued for over a half a century. This process finds it's beginnings
in the ideas and machines that were spawn by the industrial revolution.

To give credit where it is due, the abacus holds the title of being the oldest digital calculator
known to man. It is a clever device that is still in use today. The type writer became part
of what we think of today as a PC or personal computer. It allows man to input thought
to a paper medium. As well, the paper serves as storage device for the information that
was entered on it. The typewriter has no processing ability. If you could mix the abacus
with the type writer we'd be getting somewhere. The mechanical type writer was invented
around 1867 by Christopher Sholes. Remarkably, the basic QWERTY pattern he chose,
that placed the letters of the alphabet into their relative positions on the keys hasn't
changed to this day!

Some looms in England were controlled by paper scrolls with holes in them that were
interpreted mechanically to stitch now famous, highly complicated patterns such as the
paisley pattern into the weaves of cloth. The output of this process was the woven cloth.
Output is another aspect we include in today's definition of what is a computer. The
patterns these machines created were not unlike the graphics we ask the computer
to produce today. These looms were really the first digital sequencers as they took
sequences of digital signals (there is is a hole, there isn't a hole) and interpreted the
combinations of these marks as instructions. Being able to execute a series of instructions
is a also part of the basic notion we have of what constitutes a computer.

A mathematician named Charles Babbage invented the first mechanical calculator which
apparently frustrated him all his life. This sounds like it may have been the world's first
computer. Punched paper scrolls were also used to control scrolls in player pianos. At
the turn of the century punch cards were being created to process statistics on immigrants
coming into the United States. Digital thinking has been around for a while!
 
 
 Digital Thinking

 When we say digital thinking we are speaking of the fact that a machine really can only
 be instructed to do something using a switch of some sort. Turn the switch on turn it off.
 This all or none process is also called binary as there are only two states involved.
 As with the looms a series holes or the absence of holes can represent more complex
 instructions. While the loom and the piano scroll interpreted the presence or absence of
 a hole as a digital one or zero the electric computer sees combinations of switches turned
 on or off as instructions. A long row of switches in the matrix of a square of silicon can
 be individually set on or off to create an instruction a machine can understand. This 
 language which is the native language of the machine is called machine language.

 The human can interpret machine language relatively well easily because the rows of
 switches turned on or off can be thought of as being 1s and 0s in a binary counting
 system. A long combination reduces to a single number. Conversely the number, can 
 be used to restore the particular combination of switches.

 A binary system counts the  same way a decimal system is used except, instead of 
 changing columns when 10 is reached, columns are changed when 2 is reached. The 
 following table shows how a computer counts to 8.
 
 
 Decimal   Binary 
 0   0
 1   1 
 2   10
 3   11 
 4   100
 5   101
 6   110
 7   111
 8   1000

 The computer relates to 1 and zeros so besides being comfortable with a binary system
 based on 2s, the computer also uses counting systems based on base 8 (octal ) and 16
 (hexadecimal). It does decimal to accomodate humans but is really better suited to base
 2 systems or their multiples. 

 Besides counting, these switch patterns can be designed be adapted do different tasks, 
 perhaps in a house to turn down the temperature or turn off a light. In fact many appliances
 today use simple processors are are indeed a variety of computer.
.

These early developments were early indicators of what the computer would become in
our day. Machines were particularly adept at executing long, tedious and redundant
executions of patterns. It was also clear from early on that machines would make excellent
calculators or arithmetic processors. Early on it was discovered that machines could easily
be adapted to execute sequences of instructions which really were programs. All these
ideas, input, output, storage, processing instructions and doing calculations are at the heart
of what we think of as the modern computer.

Electricity

Computing didn't take off in the modern sense until the idea was coupled with electricity.
The telegraph system used by the rail lines was the precursor to the switching technology
that would be used in computers. The morris code of the telegraph operator was using
a digital medium The click or absence of a click was a form of binary communication..

The invention of the tube made possible the monster tube computers such as ENIAC that
were created during the Second World War. The tube was an analog device. The tube
could allow different flow rates of electrons to pass through it. It was like a continuously
adjustable valve. It could be operated digitally. It could be turned flat on or off. In this
sense it became a switch and could operate as a digital device. This switching on and off
was very hard on the tubes physically. The tube systems were always breaking down and
generated a huge amount of heat.

To the rescue came the transistor. The transistor run much cooler than tubes and was much
smaller. This began the long lasting trend of miniaturization of computers. The IC or Integrated
Circuit allowed further reductions in size, allowing whole circuits to be put on a single chip.
The terrific advances in computer technology have allowed computers that once filled rooms
to be fit into devices you can now hold in your hand.
 

Von Neumann Model

Surprising in all this time, many aspects  of the computer have remained constant. Most of
the popular original computer languages are still in use! How data is stored on magnetic disk
or tape today is largely the same process that was invented when magnetic tape was created
by gluing rust to paper. As mentioned earlier the QWERTY keyboard design remains in use
largely unchanged for over a hundred years. The set of elements that make up the computer
work faster, are smaller and much more capable but characteristically they haven't changed
much over the last half a century.

The famous mathematician and physicist, John Von Neumann made a study of the ENIAC
computer and in 1946 proposed a virtual computer where programs and data would be
stored in primary memory that could be accessed quickly and sequentially by a processor
and long term memory would be provide a secondary area to store information. The virtual
computer he described then is today called the Von Neumann architecture and remains the
model of how modern computers operate.
 

Diagram of the basic components of the computer

                                                    MEMORY
                          /* primary memory loaded with the programs and data */
                                                           |
/* keyboards or mice*/ INPUT    ---> CPU --->   OUTPUT /* printer or monitor*/
                                                           |
                                                   STORAGE
                             /* Persitent memory devices like hard disks, tape or CDs */
 

Languages

We mentioned earlier that programs were lists of instructions. Even if you adjusted the
medium You couldn't though use the piano scroll on the weaving loom. The instructions
would make no sense. They really represented different machine languages custom
designed to work within the context of that device. Computer languages have grown
from their early beginnings as lists of instructions written in the native machine language
to abstract high-level dialects that can be used on a large number of different machine
types.

Machine Language

The first computers were programmed without languages! An operator would bring in
a switch board and physically switch the computer to instruct it! The computer itself
understands machine language, sets of switches that make up the processor's registers
which are switched either on or off.  Even at this stage of the game, though the command
combinations had not yet been formally documented, the machine was being programmed
in in the patterns that constituted it's machine language.

Assembly Language

It soon became apparent certain sequences would be repeated over and over again. These
instructions, were assembled into short sequences that could be supplied in sequence to the
computer to save time. Whole collections of these assembled instructions became known as
the assembly language for the machine.

Higher Level Languages

Later sets of assembly language instructions were collected in longer routines or functions.
Sets of routines became known as higher level programming languages. Fortran is one of the
oldest of these higher level languages. C and Basic are also examples.
 

Operating Systems

When storage, memory, and input and output devices were integrated with the central
processing unit, a program was needed to coordinate their collective activity as a system.
This was the task that the operating system was invented to perform. The operating
system's main role is to coordinate the activity of collection of hardware devices that
are attached together to form what we call a computer system. The OS manages the
allocation of memory, the activities of the IO devices and all the other peripherals that
make up the system. The operating system also brokers the messaging that goes on
between the user via input and output devices, the programs that are running on the
system and the hardware that the programs are running on. Another important role the
OS supplies is loading itself on the machine in what is called the boot process.

When a machine is turned on, the first step that has to occur is the system has to 'boot'.
What this means is that the first program, the operating system must somehow install
itself on the machine. There is a short exchange between a storage disk and the cpu
to say where to start loading and the operating system program is loaded and all the
variable values it describes are initialized with appropriate starting values.

A Start to Finish Scenario

Once the operating system is running, a shell is supplied to the user, either a command
line prompt or a visual graphical user interface, (GUI). The shell or the GUI  is itself a
program that supplies a number of commands the operating system defines which the
user can use. We might use the shell to input a request for a program to run. The
operating system interprets this message and accesses the hard disk to find the requested
program, transfers it to primary memory, from where the cpu can run the contained list
of instructions. Any data that might be generated for storage may then be written out to
the hard drive, again coordinated by the operating system. Finally the system has to be
turned off in an orderly fashion, in a sort of reverse order of the boot process. All these
activities are coordinated by the operating system.
 

Compilers and Interpreters

Languages like C require a compiler that processes a programmers list of instructions
into the binary, machine language that the processor uses natively. Binary instructions
are the most efficient and fastest running program form because they interact directly
with the machine's registers at the machine language level. Some languages were created
to take advantage the shell commands that were provided by operating systems. These
scripts were not compiled, rather were interpreted to run in an operating system shell.

Some languages like Java and Pascal are both interpreted and compiled. Why the extra
steps? There are certain advantages conferred by the two stage process which leads us
finally to our discussion of Java.
 

Java, a Next Generation Language

Historically, Java may be thought of as a 5th generation language. We can count machine
language as first generation, assembly the second and the first high level languages such
as Fortran and PL/1 as third generation. The fourth generation comprised a number of
newer high level language were invented that were based on different approaches to
problem solving. Examples of fourth generation languages were LISP and PROLOG.
One of these new languages was Simula 67 which Alan Kaye the inventor of SmallTalk
said was the world's first object-oriented language. It was Alan Kaye that formulated
the key ideas of object-oriented programming and the language he invented, SmallTalk
became the first widely known object-oriented language. Efforts were made to make
other languages object-oriented, and so dialects like Nicklaus Wirth's Pascal were
released in object-oriented versions. (Delphi is the child of this movement). Also, Bjarne
Stroustrup in the early 80s created an object-oriented extension of C called C++. Java
may be described as the first 5th generation object-oriented language. Java builds on the
strengths of the fourth generation that that went before it.
 

Table showing the references used in creating the Java language
 
 The Java Language Specification 
  Gosling, Joy & Steeles, Abridged references (titles and authors)

 The following references show Java was built in light of the best features of  many
 languages, and to this extent is a next generation, state-of-the art programming language. 

1).Dylan Reference Manual, Apple Computer
 2) Common Lisp Object System Specification, Bobrow, Daniel G., Linda G. 
     DeMichiel, Richard P. Gabriel, Sonya E. Keene, Gregor Kiczales,and David A. Moon.
 3) The Annotated C++ Reference Manual, Ellis, Margaret A., and Bjarne Stroustrup
 4) Modula-3 Harbison, Samuel
 5) Hints on Programming Language Design. Hoare, C. A.
 6) IEEE Standard for Binary Floating-Point Arithmetic. ANSI/IEEE Std. 754-1985.
 7) The C Programming Language Kernighan, Brian W., and Dennis M. Ritchie.
 8) Object-Oriented Programming in the Beta Programming Language, Madsen, 
     Ole Lehrmann, Birger Møller-Pedersen, and Kristen Nygaard.
9) The MesaProgramming Language Pr, Mitchell, James G., William Maybury, and Richard Sweet.
10) The C++ Progamming Language,Stroustrup, Bjarne
11) The Unicode Standard: Worldwide Character Encoding, Ver.1.0 , The Unicode Consortium

Java Builds in Network and Database Support

Java had the advantage of being developed at a time when many Internet and database
standards had been ironed out. The TCP/IP protocol of the Internet had become the
accepted Internet communication protocol. HTML and HTTP were also established
as the dominant protocol being used on the world wide web. SQL, the language used
to communicate with relational databases was also standardized in version SQL/92.
Unicode is an ISO supported character set which supports over 35,000 international
was largely accepted as a workable way of organizing the many different characters
sets that were in use to describe world languages.

Java was created with Unicode being the default character set of the language itself
so it by nature lends itself to internationalization. Java adds the ability to work with
databases, networks and the world wide web right into the language seemlessly via
it's library packages.
 

Java, A Simpler Object-Oriented Language

From the beginning the Java programming language was designed to be a simple and
practical object-oriented language. Simple is a relative term. Java is simpler than C++.
It is really a sibling of C and C++, sharing many features and much of the same syntax.
It is simpler than C++ as many features provided in C++ have been omitted in Java.
As an example, C++ has a couple of ways to reference variables, either by the dot
operator or by pointers. Java picks one way. Java has the dot operator but drops
the pointers. Dropping pointers also gets rid of one of the areas where C and C++
tends to introduce errors into code. Pointers are also difficult to read and maintain.
By dropping pointers the language becomes easier and the time it takes to develop
bug-free code is reduced.
 

The Java Virtual Machine

As mentioned earlier, programming languages are compiled, interpreted or both. C is a
compiled language. The C code a programmer generates is processed by the compiler
to generate binary code that is the native language of the machine that the compiler is
running on. Binary code is very efficient and so runs very quickly on it's native platform.

A platform is the unique combination of machine and operating system. The machine
is composed of a central processing unit (CPU), a motherboard and all the peripheral
items we need to interact with the computer. Really what defines the platform at the
machine level is the machine language that the CPU uses. For instance both AMD
and Intel processors use the assembly language that has evolved with the CPUs that
have powered the IBM PCs since 1982. Though the chips are produced by different
vendors, computers that run on x86 machine code are referred to as IBM PCs.

The other part of the platform is the operating system. There are a number of different
operating systems being used, including several dialects of Windows and Unix, Linux
(really a Unix variant), the Mac OSes, BeOS and other less famous OSes. Each of
these operating systems if they were to run on the same machine would still represent
a different platform. A C program would need to be compiled seperately for each and
every one of these platform it runs on. An executable file for a computer game like
'Doom ' that runs on an PC running Windows 98 won't run on a PC running Linux or
a Mac running OSX or on a Sparcs machine running Solaris. This incompatibility of
different platforms has been a major problem for large organizations from a user,
communications and maintenance point of view.

This is one of the reasons the authors of Java selected to use an interpreter. The Java
virtual machine 'abstracts' away the differences between the machines and provides
a single 'virtual machine' to interface to a java program. This means a java program
compiled to run on the virtual machine will run on any platform where the interpreter,
the JVM, is installed. Corporations are attracted to this as the java virtual machine
in a sense creates the illusion that all the companies machine are running the same
platform.

Disadvantages of an Intrepreter

The biggest disadvantage of the interpreter is that it slows down a program's execution.
Not so long ago this would have been a potentially fatal weakness. Thanks to the
relentless improvements in new processors this is quickly becoming a non-issue. Just
as a 286 struggled to render Windows, so did a 486 or early Pentium struggle with
running Java with it's interpreter. At processors speeds over 300MHz the interpreter's
presence is hardly noticeable. At speeds approaching the 1000MHz the interpreter's
effects are no longer a consideration. (Another interesting development is the advent
of commercial programs such as Excelsior's 'Jet' that are designed to create native
executables for specific platforms from Java code. This would be handy where a
programs speed of execution was critical. )
 

Advantages of the Java Virtual Machine

The Java Virtual Machine is an interpreter, a translational program that runs on different
platforms. There is a Java Virtual Machine (JVM) defined for each popular platform.
Whether the Mac, the PC running Windows or the PC running Linux,  the JVM takes
care of translating Java code which has been created to run on the JVM to the platform
which the JVM is running on.

Strong Typing

Because the Java source code is written to run on a single virtual machine, the details
of the length and type of allowed variables do not vary from platform to platform.
Strong typing refers to the fact for any variable type, it can have only one size and
set of properties. An int type is 32 bits long once and for all and forever! A char type
is a 2 byte, unsigned value regardless of the platform, software vendor or operating
system. This allows Java to define a small, tightly group of variable types to store data
that will be consistently rendered regardless of the machine the program is running on.

Improved Security

This leads to improved security as every value can be tested to see that it meets the
criteria of strong typing. The java virtual machine also adds a security gateway at the
junction where class bytecode enters the interpreter. The java virtual machine does
different types of runtime checking. One thing it checks for is to see that arrays are
not written out of bounds. Besides being a program error this is also a security issue
as this prevents bad things from being written purposely to memory areas that are
written out of bounds. The runtime environment can also check objects that are loaded
dynamically (at runtime) to be sure they conform to object type they are suppose to be.
 

Fewer Errors and Easier Memory Management

The Java Virtual Machine provides a background thread called the garbage collector
that collects memory that has been allocated but is no longer being used. This gets rid
of a class of errors called memory leaks. This, coupled with the fact that Java doesn't
allow pointers another major bug producer, makes Java less susceptible to error,
easy to debug and a faster environment to develop in.
 

JVM Terms

The Java compiler javac, converts java source code into architecturally neutral
bytecode. The Java Virtual Machine, started by the java command takes this
bytecode and translates it into the given platform's native instruction set.
 

Growth of Java Use

Since Java's public release in summer of 1995, the number of Java users has more or
less doubled every year. By the summer of 1999, over 1 million copies of the jdk 1.2
were downloaded from the net. By May of the year 2000, 3 million copies of the Java
2 Developer's kit had been downloaded. A magazine article issued in January 2000
stated that the Java development community consisted of about 2.5 million users. The
latest report from Sun's JDK download site shows that as of June 2001 there had
been over 5 million downloads of the Java Standard Edition.

What's at stake?

The reason Java is not 'just another language' is it's portability threatens proprietorships
associated with operating systems, most notably Microsoft's. In what may be considered
a natural response, Microsoft has tried to splinter the movement to Java first by supporting
a non-compliant, Microsoft only version of Java, then by refusing to support newer versions
of Java. Microsoft lost the lawsuit with Sun over Java and the issue sits at an impasse.

Microsoft has the clout to dampen any movement with 90% of the world's PC's running
Windows. Sun wisely has provided an 'end run' to MS's resistance by releasing 'plug ins'
for the browsers including Explorer to obtain compliance with the latest version of the jdk.
The downside here is that the client has to load the java runtime environment where if
there was more cooperation, Java would come preloaded with Windows. Netscape,
like Microsoft, has been a generation behind in supporting Java, so the plug-in is a general
solution for tardy support.

By the summer of 2001, Java appears to have earned major acceptance by industry world-
wide. The latest Netscape, version 6.x, supports the jdk1.2 and the java swing visual
components.

With the recent release of Microsoft's .net architecture and the release of an new language
specificaton called C#, that has some of the features of Java, it seems that Microsoft has
decided to continue to compete with rather than join the Java movement. The confirmation
of this is Microsoft's dropping support of Java from it's developer's suite, replacing it with
C#.  Interestingly, Microsoft continues to support, Java, if quietly, on it's server based
software.

The war continues. Just today, July 18, 2001 Microsoft said it will not include the java
runtime in it's new OS XP. It seems having Java ready as a plug-in was the right strategy
for Sun. At this time, Java seems to be winning the support of developers. A recent
Gartner survey indicates that Java will be the most used development language by the
year 2002.
 

For Those Who Come From C and C++

Java is like a simplified C++. It has no pointers, nor does it have preprocessing. Also
it is more object-oriented in that it has no global functions or variables. (Even the main( )
method is enclosed in a class.) Java also only supports single-inheritance rather than the
multiple inheritance supported by C++. (Java has a special structure called an interface
that defines abstract methods and constants. Interfaces are exceptional and are allowed
to multiply inherit.)
 

Device API's 'Small, Smaller and Smallest'

Recently Sun did some house cleaning and divided the various API's into three divisions.
The Java Micro Edition acts as an umbrella for everything small and aimed at the
comsumer and embedded market. It includes the following older categorizations (API's)
as well as spec's for devices such as set top boxes, screenphone, wireless car phones
and digital assistants.

Personal Java   -'small', for consumer device, core and opt. extensions, fully upwards compatible
EmbeddedJava   -'smaller', PersonalJava subset for smaller processing resourses i.e cell phones
JavaCard         -'smallest', for whatever processing you can miniaturize on a 'smart card'
 

The JDK releases which now refer to the Java Standard Edition to date are:

1)  JDK 1.0 and 1.0.2
2)  JDK 1.1. through 1.1.8 (current)
3)  JDK 1.2.x now called Java 2 sdk ver. 1.2 ,1.2.1 and 1.2.x // + few more minor releases
4)  JDK 1.3.1 has now been released and JDK1.4 is in beta.
 

The Enterprise Edition is a third version of the JDK which appends to standard
edition support for Servlets and Java Server Pages, Enterprise Java Beans. In addition
there are APIs such as the Java Naming and Directory Interface, the Java Messaging
Servive, Java Transaction Service and Java Mail. The J2EE also has tools to test and
support these API's includes the CloudScape, all Java database.
 

ABI Application Binary Interface

The Application Binary Interface specifies the format of an executable file for a
specific platform. (i.e. the address space of a processes or details regarding the use
of cpu registers etc.). ABI's are the terrain of the compiler writer. A program that
conforms to a system's ABI will run on any processor that compiles with that ABI.
Every cpu has it's own native ABI. The JVM is implemented for each architecture
so that the java bytecode can run on that system.

An interesting twist is other language compilers, like COBOL , have been  ported to
produce java bytecode to run on Java Virtual Machines. In fact over a 130 languages,
have been ported to run on Java's JVM. Languages like Lisp Tcl, Python, Eiffel,
Smalltalk and Fortran have been ported to run on the Java Virtual Machine which
gives these languages the same platform independence that Java enjoys.

Dr. Robert Tolksdorf maintains a site that keeps track of the languages ported the
JVM which you can view a http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html

Because of C and C++'s use of pointers these languages don't port well to Java's
binary environment. (Microsoft's new C# language, though a copy of Java in many
ways, sides with C and C++, allowing a limited use of pointers.)
 

Applications, Applets, Servlets & Enterprise JavaBeans

The stand-alone application is one of four contexts for writing java programs. The
other three are essentially variations of the same theme where the program runs in
a greater context supplied by another program. The Applet, Servlet and Enterprise
JavaBean, all run in the context supplied by another environment.

Applets

Applets run in the context of the web browser, referenced from within the context
of an HTML page. Applets lost favor for while partly due to the time it required to
get the java runtime environment up and running. More pragmatic solutions like
javascript filled the space applets might have occupied. Applets have become
increasingly relevent with the advent of signed applets which can be made secure for
commercial and privacy interests. Personal hardware has improved to the point that
the overhead of running applets is no longer as significant a factor. Applets are shining
in commercial web applications, providing complicated front-ends for net applications,
which connect back to the server via a socket or by tunnelling the http protocol.
 

Servlets

Servlets are similar in architecture to applets but run in the context supplied by a
web server. Servlets are providing a better means of handling the web client / server
interface than more traditinal solutions like CGI. A cousin of servlets, are JSPs or
Java Server Pages that are a very popular means of blending java's connectivity
features into the context of the web page.
 

Enterprise JavaBeans

Enterprise JavaBeans are designed to provide data resource support for the back
end of a companies network architecture. Again, like applets and servlets, EJB's run
in the context of another program. In the case of Enterprise JavaBeans, the program
is called the container.
 

Hello World in Java

An introductory discussion of a programming language would not be complete without
looking at a "Hello World" program in the language being studied. Open a plain text
editor and enter the following code.

Example

class HelloPlanet{
  public static void main(String [] args) {
     System.out.println("Hello Planet");
     }
  }

Analysis

Lets analyse this code. The first word is 'class'. This word is a Java keyword, a word
reserved exclusively for Java's use. It identifies the structure which includes everything
written inside the zone defined by the first and the last curly brace. This range is called
the scope of the class. The class is the fundamental unit that java code is defined in.
Most everything written in Java is contained within the class definition. The only thing
written outside the class definition is stuff to do with packages which are directory
level structures that can be used to group sets of related classes. Notice even the
main method is included inside the class.
 

The word HelloPlanet following the class keyword is the unique identifier that provides a
name for the class. Identifiers can't be keywords like 'class'.

The curly brace, following the identifier begins what is called the scope of the class.
It is a range or block that is ended by the opposite curly brace located at the very
end of the code.

Inside the class is one method. It is the main method. This is a special method that
defines the start or entry point of the section of code that is contained in the class.

The main method has a return type which is void. This means main doesn't return
anything. It has two modifiers, one public means that the method is available from
any Java object in any package. It means public access. The static word means
main exists only in the class definition. It is defined only once.

The System.out.println("Hello Planet"); statement is a line which prints the enclosed
String literal, "Hello Planet" to console, in other words the monitor.

The main method ends with a curly brace. The already mentioned class ends with a
curly brace and the code is finished. After this we could tune into the Compiling and
Executing Instructions provided below, starting in at number 2. This list summarizes
the steps that are taken to write compile and run java code.

Compiling and Executing Java Source Code

1. Install Java
2. Create your source code in a straight ASCII editor
3. Name the file identically to the class name + the .java extension
4. Open a Dos/Unix window and type javac Name.java and enter // to compile
5. If the compilation was successful the Dos prompt returns, then type java Name
    // to run the interpreter