write once run anywhere
Desktop, mobile, card, and so Java programmers,
organizations
Developed By : James Gosling
Owner : Sun Microsystems
Released in : 1995
Stable Release : Java Standard Edition 7 (1.7.0)
OS : Cross Platform (Multi Platform)
Extensions : .java, .class, .jar
JAVA Platform It is Platform Independent. It compiles Java language code in Java bytecode , not in Machine code. A major benefit of using bytecode is porting.
Virtual machine
ByteCode
//
/* */
/**
*@author yuri...
*/
class Hello { public static void main(String args []) { System.out.println (“Hello"+ "World”);
} }
JDK : JAVA Development Kit
JVM : JAVA Virtual Machine
JRE : JAVA Runtime Environment
javac : JAVA Compiler
JVM : JAVA Virtual Machine
KVM : Kilobyte Virtual Machine
CVM : Card Virtual Machine
DVM : Delwik Virtual Machine
Java programs need to be compiled only once.
When a class is defined as public, class name and file name must be same.
”;” can be put anywhere before a new statement.
Java does not support operator overloading.
Operator “+” is by default overloaded in JAVA.
Template,
State and behaviour of object at run time, Abstract class ,Final class
A 100% abstract class,
A contact for what a implementing class can do.
Behavioural purposes
Class can implement multiple interfaces
Primitives, Reference, Local variables Arrays, Final variables ,Transient
static
abstract
final
Keep data protected
Keep services open
Setters and getters method
Re-usability
Sometimes we have no implementation
Is-a vs has-a relationship
Overloading
Overridding
Need?
Default constructor
Constructor overloading
Constructor calls in inheritance tree
postfix expr++ expr--
unary ++expr --expr +expr -expr ~ !
multiplicative * / %
additive + -
equality == !=
relational < > <= >= instanceof
shift << >> >>>
bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
logical AND &&
logical OR ||
ternary ? :
assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=
VS
String user1 = "YuriLz";
String user2 = "YuriLz";
String user3 = "Yuritta";
String user4 = new
String("YuriLz");
String user5 = new String();
String user6 = new String();
user5 = "YuriLz";
user6 += "YuriLz";
System.out.println( (user1==user2)? "Equal" : "Not Equal" );
System.out.println( (user3==user2)? "Equal" : "Not Equal" );
System.out.println( (user1==user2)? "Equal" : "Not Equal" );
System.out.println( (user4==user2)? "Equal" : "Not Equal" );
System.out.println( (user5==user2)? "Equal" : "Not Equal" );
System.out.println( (user5==user6)? "Equal" : "Not Equal" );
System.out.println( (user5.equals(user2))? "Equal" : "Not Equal" );
System.out.println( (user5.equals(user3))? "Equal" : "Not Equal" );
(user1==user2)? "Equal" : "Not Equal" );
(user3==user2)? "Equal" : "Not Equal" );
(user4==user2)? "Equal" : "Not Equal" );
(user5==user2)? "Equal" : "Not Equal" );
(user5==user6)? "Equal" : "Not Equal" );
(user5.equals(user2))? "Equal"
: "Not Equal" );
(user5.equals(user3))? "Equal"
: "Not Equal" );
~$ javac StringsExemple.java
~$ java StringsExemple
Equal Not Equal Not Equal Equal Not Equal Equal Not Equal