chapter 1: introducing java. 2 introduction why java applets and web applications very rich gui...

5
Chapter 1: Introducing JAVA

Upload: jody-cameron

Post on 13-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object

Chapter 1: Introducing JAVA

Page 2: Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object

2

IntroductionWhy JAVA

• Applets and web applications

• Very rich GUI libraries

• Portability (machine independence)

• A real Object Oriented Language

• Support International character sets (Unicode)

Page 3: Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object

3

Program Development• Editing (any text editor or IDE)

• Compiling (javac) Java Object (byte) code

• JVM interprets that code and translates it to machine language code

• Try installing SDK 1.4.2 then use a simple editor edit, compile and run a simple program. See on-line hand out. Do it for the applet too.

Page 4: Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object

4

OOP in JAVA• What is an object? Any thing around us• A class is a convenient way to group things• It defines a set of variables called class data

members (attributes) and a number of functions operating on these attributes (methods)

• Example: CowboyHat, hatOn=false, putHatOn(), takeHatOff()

• Encapsulation: Hiding implementation• Advantages: less error-prone, easier to maintain

Page 5: Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object

5

JAVA’s Class Library• Very very rich Library:

– Java.lang, java.io, java.util, javax.swing, java.awt, java.awt.event, etc.

• To include a library in your program you use the import statement (import java.io.*;)

• Every Java application contains at least one class that defines the main function, the starting execution point. Its form:(public static void main (String [] args) { })