Vous êtes sur la page 1sur 27


Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991 name with Oak In 1992 this can be used in hand held devices 1993 this cab be used in WWW applications the same team in 1994 Hotjava bower developed ,it is more popular internet users. is

This language was initially called Oak but was renamed Java in 1995 1996 java itself established not only internet program but also general purpose, and OOP 7/13/12 languages.

The Bytecode

Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM). That is, in its standard form, the JVM is an interpreter for bytecode. This may come as a bit of a surprise


Java Features


Secure Portable Object-oriented Robust Multithreaded Architecture-neutral Interpreted

7/13/12 High performance


Java is simple because there are various features that makes the java as a simple language. Programs are easy to write and debug because java does not use the pointers explicitly, operator overloading , multiple inheritance, process header files, goto stement



To be an Object Oriented language, any language must follow at least the four characteristics.

Inheritance Encapsulation Polymorphism Dynamic binding



Java is a strictly typed language, it checks your code at compile time.




strong automatic

memory garbage

allocation and

collection mechanism.

It provides the powerful exception handling and type checking



Multi thread means handling multiple tasks simultaneously

Java supports multithreaded programming, which allows you to write programs that do many things simultaneously.

Java is also a Multithreaded programming language.



One of the main problems facing programmers is that no guarantee exists that if you write a program today, it will run tomorroweven on the same machine Operating system upgrades, processor upgrades, and changes in core system resources can all combine to make a program malfunction

The Java compiler does this by generating byte code instructions, to be easily interpreted on any machine and to be easily translated into native machine code

The compiler generates an architecture-neutral object file format


Interpreted and High Performance

Java enables the creation of crossplatform programs by compiling into an intermediate representation called Java bytecode. This code can be interpreted on any system that provides a Java Virtual Machine Other interpreted systems, such as BASIC, Tcl, and PERL, suffer from almost insoluble performance deficits. Java, however, was designed to 7/13/12


Java is designed for the distributed environment of the Internet, because it handles TCP/IP protocols, HTTP and FTP are developed in java In fact, accessing a resource using a URL is not much different from accessing a file. Internet programmers can call functions on these protocols and can 7/13/12 access the files from any remote get


Dynamic Java programs carry with them substantial amounts of runtime type information that is used to verify and resolve accesses to objects at run time. This makes it possible to dynamically link code in a safe and expedient manner. Java is capable of dynamically linking in new class libries, methods and objects. 7/13/12


The feature Write-once-run-anywhere makes the java language portable provided that the system must have interpreter for the JVM. programs to be dynamically downloaded to all the various types of platforms connected to the Internet, some means of generating portable executable code is needed. the same mechanism that helps ensure security also helps create portability


Java system verify all memory access but also ensure that no virus are communicated with applet Java achieves this protection by confining a Java program to the Java execution environment and not allowing it access to other parts of the computer. The absence of pointers that


Java environment

JDK (java development KIT) collection of tools Appletviewer ( java compatible browser) Javac ( compiler) Java (interpreter) Javap( dis assembler) : convert the bytcode to program Javah : produces the header files for



Language support package Utilities package Input /Out package Networking package AWT package Applet package


Data Types, Variables, and Arrays

Integers This group includes byte, short, int, and long, which are for whole valued signed numbers. Floating-point numbers This group includes float and double, which represent numbers with fractional precision. Characters This group includes char, which represents symbols in a 7/13/12 character set, like letters and numbers.


long 64 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 int 32 2,147,483,648 to 2,147,483,647 short 16 32,768 to 32,767 byte 8 128 to 127

Floating-Point Types

Double 64 4.9e324 to 1.8e+308 float 32 1.4e045 to 3.4e+038 Literals

Integer Literals Floating-Point Literals Boolean Literals 7/13/12

Escape Sequence \ddd

Character Escape Sequences

Octal character (ddd)


\uxxxx Hexadecimal UNICODE character (xxxx) \ \ \\ \r \n Single quote Double quote Backslash Carriage return New line (also known as line



The variable is the basic unit of storage in a Java program. A variable is defined by the combination of an identifier, a type, and an optional initializer. In addition, all variables have a scope, which defines their visibility, and a lifetime Declaring a Variable
type identifier [ = value][, identifier [= value] ...] ; 7/13/12


One-Dimensional Arrays type var-name[ ]; int month_days[]; int month_days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; Multidimensional Arrays int twoD[][] = new int[4][5];

Sample program

/* This is a simple Java program. Call this file "Example.java". */

import java.io.*; import java.util.*; class Example { // Your program begins with a call to 7/13/12

import java.io.*; import java.util.*; class Example2 { public static void main(String args[]) { int num; // this declares a variable called num num = 100; // this assigns num the value 100 7/13/12

Using arrays

class Average { public static void main(String args[]) { double nums[] = {10.1, 11.2, 12.3, 13.4, 14.5}; double result = 0; int i; for(i=0; i<5; i++)

Two dimensional arrays

class TwoDArray { public static void main(String args[]) { int twoD[][]= new int[4][5];

01234 56789 10 11 12 13 14 15 16 17 18 19