Presentation is loading. Please wait.

Presentation is loading. Please wait.

Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.

Similar presentations


Presentation on theme: "Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural."— Presentation transcript:

1

2

3 Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural programs Functions are called methods Unit of a program is the class from which objects are created Automatic garbage collection Single inheritance only

4 Each class contains data and methods which are used to manipulate the data Programs are small and portable Multithreaded which allows several operations to be executed concurrently A rich set of classes and methods are available in java class libraries Platform Independent Case sensitive

5 Edit – use any editor Compile – use command ‘javac’if your program compiles correctly, will create a file with extension.class Execute – use the command ‘java’

6 Keywords are special reserved words in java that you cannot use as identifiers for classes, methods or variables. They have meaning to the compiler, it uses them to understand what your source code is trying to do.

7 class FirstPro { public static void main(String args[]) { System.out.println("Hello World!“); } First java Program

8 All java source files must end with the extension ‘.java’ Generally contain at most one top level public class definition If a public class is present, the class name should match the file name

9 If these are present then they must appear in the following order. Package declarations Import statements Class definitions

10 An identifier is a word used by a programmer to name a variable, method class or label. Keywords may not be used as an identifier Must begin with a letter, a dollar sign($) or an underscore( _ ). Subsequent character may be letters, digits, _ or $. Cannot include white spaces. ref: Note

11 Type identifier; Type identifier=initial value;

12 TypeBitsRange boolean1true, false char160 to 65,535 byte8-128 to +127 short16-32,768 to +32,767 int32-2 32 to +2 32 -1 long64-2 64 to +2 64 -1 float32-3.4E+38 to +3.4E+38 (approx) double64-1.8E+308 to +1.8E+308 (approx)

13 int grade; // an integer to hold a grade, no initial value int grade = 0; // an integer to hold a grade with initial value 0 char answer; // an answer to something – one character String name; // a string to hold a name String name = "Gumboot"; // as above, with an initial value boolean finished; // to hold "true" if finished boolean finished = false; // as above, but with an initial value

14 Declarations int grade; char answer; String name; Assignments grade = 70; answer = 'a'; name = "alan turing";

15 Data Type Default Value (for fields) byte0 short0 int0 long0L float0.0f double0.0d char'\u0000' String (or any object) String (or any object) null booleanfalse


Download ppt "Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural."

Similar presentations


Ads by Google