Java Overview February 4, 2004
2/4/2004 Assignments Due – Homework 1 Due – Reading and Warmup questions Project 1 – Basic Networking
2/4/2004 Hello.java public class Hello { public static void main(String[] args) { //display a greeting in the console window System.out.println(“Hello, World!”); } }
2/4/2004 What is an object? Instance of a class Basic entity manipulated in a Java program Program is made of multiple objects interacting Ex. – coffee machine – Coins, Cups, ??? Behavior – methods called on objects Classes define the behavior
2/4/2004 BankAccount.java
2/4/2004 Threads Lightweight process Would like to be able to do “two things at once” Create a thread to do each thing
2/4/2004 Threads Example // Construct an object to process the HTTP request message. HttpRequest request = new HttpRequest(connectionSocket); // Create a new thread to process the request. Thread thread = new Thread(request); // Start the thread. thread.start(); class HttpRequest implements Runnable // Implement the run() method of the Runnable interface. public void run()
2/4/2004 Graphical User Interface UIExample.java
2/4/2004 Other Helpful Hints