Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.

Similar presentations


Presentation on theme: "Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A."— Presentation transcript:

1 Chapter 1: Introducing JAVA

2 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A real Object Oriented Language (plus all the advantages of OOP) Support International character sets (Unicode)

3 3 Java Environment Java 2 platform consists of two elements: –The Java Virtual Machine (JVM) –Java Application Programming Interface (API) It is an interpreted language It was originally very slow compared to native ones. That is not valid now except in computationally intensive applications

4 4 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 JDK 5.0 (or the newest one, JDK 6.0) then use a simple editor edit, compile and run a simple program Applets

5 5 OOP in JAVA What is an object? Any thing around us A class is a a term that describes a collection of objects with common properties It is basically a convenient way to group things A class defines a set of instance variables called data members, attributes, or fields & a number of functions operating on these attributes (methods) An instance of a class is an existing object of that class Example: a Student class

6 6 OOP in JAVA (cont.) Example: CowboyHat class Class CowboyHat { String type; String color; int size; boolean hatOn; void putHatOn() { hatOn = true; } void takeHatOff() { hatOn = flase; } }

7 7 Operations on Objects Methods: putHatOn(), takeHatOff() Performing an operation on an object amounts to calling the method that defines that operation for the object. Advantages of OOP: –Intuitive modeling –easier to understand and maintain –less error-prone –Longer to design but less time to write and test

8 8 Encapsulation Encapsulation: Hiding implementation Variables and method can be hidden by using the private keyword You can change the internal details of the class without affecting other modules By using a method to set or change the values of a variable you can ensure that only legal values are set Defining a class is equivalent to defining a new data type

9 9 JAVA’s Class Library Very very rich Library: –Java.lang, java.io, java.util, javax.swing, java.awt, java.awt.event, etc. –Java.lang is automatically included 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) { }) First program


Download ppt "Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A."

Similar presentations


Ads by Google