programming in java

18
The most striking feature of the language is that it is PLATFORM-NEUTRAL language. Is the FIRST programming language that is not tied to any particular hardware or OS. JAVA programs can be executed anywhere on any system. BUZZWORDS. JAVA BUZZWORDS (Features) Compiled & Interpreted Multi-Threaded Platform-Independent & Portable Object-Oriented Simple High Performance Safe (Secure) & Robust Dynamically Linked

Upload: abhilash-nair

Post on 22-May-2015

718 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Programming in Java

The most striking feature of the language is that it is PLATFORM-

NEUTRAL language.

Is the FIRST programming language that is not tied to any particular

hardware or OS.

JAVA programs can be executed anywhere on any system.

BUZZWORDS.

JAVA BUZZWORDS (Features)

Compiled & Interpreted Multi-Threaded

Platform-Independent & Portable Object-Oriented

Simple High Performance

Safe (Secure) & Robust Dynamically Linked

Garbage Collected. Distributed

Page 2: Programming in Java

PROGRAMMING IN JAVA

-Ankita Karia

Page 3: Programming in Java

JAVA ENVIRONMENT

DEVELOPMENT TOOLS CLASSES AND METHODS.

are part of the system known as JDK (Java Development Kit).

JAVA ENVIRONMENT

Are part of JSL (Java Standard Library), also known as API (Application Programming Interface)

Collection of tools used for developing and running JAVA programs

Page 4: Programming in Java

JAVA DEVELOPMENT KIT

java –This tool is an interpreter and can interpret the class files generated by the javac compiler

javac – the compiler, which converts source code into Java bytecode

javadoc – the documentation generator, which automatically generates documentation from source code

jdb – the debugger javap – the class file disassembler appletviewer– this tool can be used to run and debug

Java applets without a web browser

Page 5: Programming in Java

EXECUTION STEPS IN JAVA To create a program in JAVA, we need to create a source code file

using a text editor. The source code is then compiled using the JAVA COMPLIER javac And then the program is executed using JAVA interpreter java.

TEXT EDITOR

JAVA SOURCE

CODE

javac

JAVA CLASS FILE

java

JAVA PROGRAM OUTPUT

Compile source code

into bytecode

INTERPRETER

Page 6: Programming in Java

HOW TO WRITE A

JAVA PROGRAM?????

C++ program

void main(){ cout<< “ My first

C++ program”; getch();}

JAVA Program class First { public static void main( String

args[]) { System.out.println(“My first

JAVA program”); }}

Since, JAVA is a true OO Language, Everything must be placed inside a class.

Page 7: Programming in Java

WHERE TO WRITE JAVA PROGRAM

TEXT EDITOR IS USED to write JAVA program

Page 8: Programming in Java

NEXT WHAT?????????? Save your program with file name same as class

name. Extension of the file is java (eg:- first.java)

Page 9: Programming in Java

NEXT WHAT?????????? Compile your program using javac compiler. For that go to DOS prompt;

Go to drive where your java file is stored

Page 10: Programming in Java

NEXT WHAT?????????? STEP 2

Page 11: Programming in Java

NEXT IMPORTANT STEP

Page 12: Programming in Java

Compiling USING javac compiler

Page 13: Programming in Java

EXECUTION OF BYTECODE USING JAVA INTERPRETER

Page 14: Programming in Java

EXPLANATION OF PROGRAM

public Is an ACCESS SPECIFIER that declares main as unprotected & thus is accessible to all classes

static Declares the method as one that belongs to entire class

void Means main does not returns value

args Contains an array of objects of the class type String

println Is a method and it is a member of out object

out Is a static data member of System class.

System Is a class

System.out.println is similar to “cout” of C++

Page 15: Programming in Java

MORE ON BASICS OF JAVAOUTOUT STATEMENTS:

println(name);prints out what is stored in name, then goes to a new line

print(name);prints out what is stored in name, but does not start a new line

print("My name is " + name);put text in quotesuse + to print more than one item.

COMMENTS: JAVA permits both single-line and multi-line comments.

Single-line comments starts with //

Multi-line comments starts with /* and ends with */

Page 16: Programming in Java

MORE ON BASICS OF JAVA Every JAVA statement must end with a semicolon. JAVA is case-sensitive. Thus, Main is different from main in JAVA.

CASCADING IN JAVA + is used to print more than one item.E.g.:-System.out.println(“GOOD MORNING”);System.out.println(“FE6”);System.out.println(“CP II Lecture”);

ORSystem.out.println(“GOOD MORNING”+”\n FE6”+”\t CP II Lecture”);

Page 17: Programming in Java
Page 18: Programming in Java

HOW TO CREATE BYTECODE

javap –c first

FILE NAME