Transcript
Page 1: Java for the Beginners

“Java” – for a beginner

By: Biswadip Goswami

(c) Biswadip Goswami, [email protected]

Page 2: Java for the Beginners

What are we going to venture !

• The Platform.• Java Virtual Machine.• The Programming Environment.• Some fundamentals (datatypes etc.).• Structure of a Java Program.• Mistakes we make while writing the code.

(c) Biswadip Goswami, [email protected]

Page 3: Java for the Beginners

The platform

Java is a whole platform !Huge libraryLots of reusable codeExecution environment providing services as • Security• Portability• Automatic garbage collection and more

(c) Biswadip Goswami, [email protected]

Page 4: Java for the Beginners

The Virtual MachineJVM or Java Virtual Machine. • Platform independent execution environment• Convert ByteCode to machine code• Mimics a real Java processor• The ByteCode is executed regardless of the

Operating System• A ByteCode stream: 03 3b – The mnemonics • iconst_0 // 03• istore_0 // 3b

(c) Biswadip Goswami, [email protected]

Page 5: Java for the Beginners

JVM and Garbage Collection:JVM stores all objects by the java applications and Garbage Collection is a process of automatically freeing those objects which are not referenced by the program any more.Garbage collector also stops heap fragmentation.

(c) Biswadip Goswami, [email protected]

Page 6: Java for the Beginners

Some IDEs Available:

• NetBeans [http://www.netbeans.org]• Eclipse [http://www.eclipse.org]• JBuilder 7

[http://www.borland.com/jbuilder]• Oracle9i JDeveloper

[http://www.oracle.com/ip/develop/ids/]

(c) Biswadip Goswami, [email protected]

Page 7: Java for the Beginners

JARGONS !

• JDK – Java development kit• JRE – Java runtime environment• SE – Standard Edition• EE – Enterprise edition• ME – Micro edition• J2 – Java 2• SDK – Software development kit• Netbeans – there is no acronym sorry !

(c) Biswadip Goswami, [email protected]

Page 8: Java for the Beginners

The Programming Environment !

(c) Biswadip Goswami, [email protected]

Page 9: Java for the Beginners

First Program !

(c) Biswadip Goswami, [email protected]

Page 10: Java for the Beginners

(c) Biswadip Goswami, [email protected]

Page 11: Java for the Beginners

Using Comments

(c) Biswadip Goswami, [email protected]

Page 12: Java for the Beginners

Data Types• Java is a strongly typed language• Eight primitive types in Java• Integer types– int (4bytes)– Short (2bytes)– Long (8bytes)– Byte (1byte)

• Floating point type– Float (4bytes)– Double (8bytes) (c) Biswadip Goswami, [email protected]

Page 13: Java for the Beginners

• Char type – used to describe individual characters. E.g. - \b (backspace), \t (tab)

• Boolean type – it has two values ‘true’ and ‘false’.

• After declaring a variable, it must be explicitly initialized. E.g. int days=30;

• In java declaration can be done anywhere in the code. E.g. for(int x;x<=10;x++);

(c) Biswadip Goswami, [email protected]

Page 14: Java for the Beginners

Example

(c) Biswadip Goswami, [email protected]

Page 15: Java for the Beginners

Input/OutputLets check out an example for output –

(c) Biswadip Goswami, [email protected]

Page 16: Java for the Beginners

• Console input and output in Java.• Standard output stream (System.out.println)• Standard input stream (System.in)• Methods of Scanner class reads inputs.

• Scanner(System.in)

• nextLine method – input with space• next method – input single string

(c) Biswadip Goswami, [email protected]

Page 17: Java for the Beginners

The Structure:

Any simple java program looks like<access-specifier> class <class-name>{<access-specifier> static void main(varargs){variables;functions;}}

(c) Biswadip Goswami, [email protected]

Page 18: Java for the Beginners

Troubleshooting:• Check for upper and lower case of class name

and .java program name.• Bad command or file name - check for installation• Cannot read: xyz.java – check for the file in the

current directory• Error about new language construct – check for the

latest version of JDK• Cannot find the symbol – check for the

name/keywork/identifier• Using an IDE generally saves you from setting of the

CLASSPath. (c) Biswadip Goswami, [email protected]

Page 19: Java for the Beginners

Thank you !

For assistance with your ASP.Net or JAVA requirements contact:

Biswadip GoswamiPrimary e-mail: [email protected] e-mail: [email protected]:

http://people.cognobytes.com/biswadipSkype me at biswadip.g

(c) Biswadip Goswami, [email protected]


Top Related