Howdy. 

Adrian German

dgerman@indiana.edu

http://www.cs.indiana.edu/classes/c212

We need to get some information from you first. 

Let's write a simple Java program: 

Java programs are made out of classes. 

Classes are containers: they contain members. 

Members are static and non-static. 

Members are: procedures and variables. 

There is one static member that is special: 

  public static void main(String[] args) {

  }

This is a static method where the program starts. 

Every class can have such a main. It allows the program to start. 

class One {
  public static void main(String[] args) {
     System.out.println("Howdy!"); 
     System.out.println("Howdy!"); 
     System.out.println("Howdy!"); 
     System.out.println("Howdy!"); 
  }
}

What if we use print instead of println? 

class One {
  public static void main(String[] args) {
     System.out.print("Howdy!"); 
     System.out.print("Howdy!"); 
     System.out.print("Howdy!"); 
     System.out.print("Howdy!"); 
  }
}

This is what you get now: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run One
Howdy!Howdy!Howdy!Howdy!> 

Can we write a more complicated program? 

The fundamental unit of compilation in Java is the package. 

Packages contain classes. 

You need to import the classes you need unless they are in java.lang. 

JFrame is a class defined in a package called javax.swing. 

So if you need JFrame you need to import it. 

import javax.swing.JFrame; 

class One {
  public static void main(String[] args) {
    JFrame a = new JFrame(); 
    a.setVisible(true); 
    a.setSize(300, 500); 
  }
}

Now I gave you some examples. 

Time to assign some reading. 

--