90 likes | 173 Views
Java Overview. February 4, 2004. Assignments. Due – Homework 1 Due – Reading and Warmup questions Project 1 – Basic Networking. Hello.java. public class Hello
E N D
Java Overview February 4, 2004
Assignments • Due – Homework 1 • Due – Reading and Warmup questions • Project 1 – Basic Networking
Hello.java public class Hello { public static void main(String[] args) { //display a greeting in the console window System.out.println(“Hello, World!”); } }
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
BankAccount.java http://www.nmsl.cs.ucsb.edu/~srollins/courses/cs5-m02/web/code/71/BankAccount.java http://www.nmsl.cs.ucsb.edu/~srollins/courses/cs5-m02/web/code/71/BankAccountTest.java
Threads • Lightweight process • Would like to be able to do “two things at once” • Create a thread to do each thing
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()
Graphical User Interface • UIExample.java