53511999-42187028-Basic-Java - Basic Java Introduction...

Info iconThis preview shows pages 1–21. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Basic Java Introduction Developed by Sun Microsystems. Java an island in Indonesia where a lot of coffee is grown. Designed with syntax similar to C++ syntax to help programmers in C++ migrate fast to Java. Points about Java No pointers, structure and union, operator overloading, preprocessors, default arguments, global variables, unsigned integers, goto, delete. The compilation of a program results in byte code. (This enables the write once run everywhere feature of java.) Byte code Advantages Makes java byte code platform independent. (Only JVM is implemented differently for different OS). Makes java program secure. JVM doesnt execute anything that might cause a security issue. Just In Time Compiler Disadvantages is that it is slower as it is interpreted. JIT compiler that comes with Java 2 that helps java byte code to compile java byte code in small chunks. Words associated with java Simple, secure, portable, object-oriented, multithreaded, robust, distributed. Deprecated: should not used. Primitive datatypes byte (1 byte), short ( 2 byte), int (4 byte), long (8 byte) float (4 byte),double (8 byte) char ( 1 byte) boolean ( 1 bit) Casting Automatic conversion: byte->short->int->long->float->double char char and boolean are not convertible to each other via casting. Casting required when destination class is smaller than the source class. Example int k=(double)3.14; Class and Object Java is an object oriented language. What is an object ? What is a class? red ball blue ball green ball Objects Ball Class Object is an entity or thing that is conceptual. Class is a template of an object. Operators + - * / % ++ -- += -= *= /= %= < > >= =< == != && || ! ? instanceof Example: greenBall instanceof Ball : returns true/false object class String It is a predefined class in java. It is not an array of characters. String literal example: "Welcome" String variables : String str="Welcome" Arrays Arrays are data structure that hold similar kind of data. int numbers[10]; int numbers={1,2,3,4}; retrieving data from the arrays: numbers[2] Points to bear in mind Java programs cannot exist without a class. You cannot have functions that are standalone. No global variables in Java. The java file must have the same name as the public java class in that file. This java file must be stored in a file called "Welcome.java". Conditional statements if (condition) statement; [else if (condition) statement;] [else statement;] switch(expression){ [case value1: statement break;] [deafult: default statement;] } n times 1 to n times Loops while (condition) { statements } do{ statements } while(condition) for(initialization;condition;iteration){} break continue Constructors and methods new Student(John,123) Constructors Named same as the class name and has no return value....
View Full Document

This note was uploaded on 12/14/2011 for the course ENPM 603 taught by Professor Kumar during the Winter '09 term at Indian Institute of Technology, Kharagpur.

Page1 / 102

53511999-42187028-Basic-Java - Basic Java Introduction...

This preview shows document pages 1 - 21. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online