Part One

Lets get started writing our first Java program

Fire up Dr.Java and paste this in or type it exactly as you see here (be careful java is case sensitive):

public class Lesson0 {
    public static void main( String[] args ) {
        
        // prints hello world
        System.out.println("hello world");

    }
}
       

Save the file, hit compile and run. You should see the following:

> run Lesson0
hello world
> 
        

What did the line with System.out.println do? What did the line starting with // do?

Part Two

Now try printing Hello Again instead. Is it clear where you have to change your program?

Part Three

Try this code:

System.out.println("hello");
System.out.println("World");
       

Now try this:

System.out.print("hello");
System.out.print("World");
       

Can you spot the difference between print and println?

Part Four

Now try this code instead:

public class Lesson0 {
    public static void main( String[] args ) {
        
        // prints hello world
        System.out.println("hello\nworld");

    }
}
       

Can you tell what \n does?

Home Work

Write a program that provides the following output

A programmer started to cuss 
Because getting to sleep was a fuss
As he lay there in bed
Looping round in his head
was: while(!asleep()) sheep++;
       

.. and if you want to learn more on your own

Figure out what \t means.

Figure out how to make a comment more than one line.

Read through the Dr.Java Book and do the exercises inside.