2. Fundamentals of Java
• Key Skills & Concepts
• History of java
• Importance of bytecode
• Java Buzzword
• Java development kit
• IDE installation
• First simple program
• Second simple program
• Data types
• Project work
• Control statement
• Sample program
• Project work
2
3. History of Java
Get_renamed
Year_1995
Oak Java
Java mainly invented for Embedded System to create software
for Microwave Ovens, Remote Controls and Toaster 3
4. C++ vs. Java
Java easier then the C++. We can learn Java without having
knowldege of C++
C++ Java
• Multiple Inheritance • No multiple Inheritance
• Pointer • No pointer
• Operator overloading • No operator overloading
• Friend function • No friend function
• Main method outside of class • Main method inside the class
• Malloc and calloc for memory • No malloc and calloc memory
management fixed
4
5. Java Bytecode
• Javac command generate
.class file
• Interpreter generate bytecode
and pass to the JVM
• JVM helps to run the code on
operating system
5
11. Eclipse IDE
• Providing environment to write multiple programming language
code (E.g. Java, php, python, c, c++ and etc.)
• We can easily design models (e.g. UML, XSD and etc.)
• Easily integrate third pary library in our code (e.g. Facebook API,
Twitter API, dropbox API and etc.)
• Eclipse helps to make test driven application
11
12. Sample Java code
/*
This is a simple Java program.
Call this file Example.java.
*/
class Example {
// A Java program begins with a call to main().
public static void main(String args[]) {
System.out.println("Java drives the Web.");
}
}
12
13. Execute Java code
You will follow these three steps:
1. Enter the program
>> CD C://path
2. Compile the program
C://path>> Javac helloworld.java
3. Run the program
C://path>> java helloworld
13
14. Data types in Java
Data Type Default Value (for fields)
byte 0 -- 8– bit
short 0 -- 8– bit
int 0 -- 32 – bit
long 0L – 64– bit
float 0.0f -- 32-bit
double 0.0d – 64- bit
char 'u0000‘ – 16- bit
String (or any object) null
boolean false – (True and false)
14
16. Java Example
• Addition of two integer Number
• Subtraction of two integer Number
• Division of two integer Number
• Multiplication of two integer Number
• Modulus of two integer Number
16
18. Java comparision
operator
Equality and Relational Operators
• == Equal to
• != Not equal to
• > Greater than
• >= Greater than or equal to
• < Less than
• <= Less than or equal to
Conditional Operators
• && Conditional-AND
• || Conditional-OR
• ?: Ternary (shorthand for if-then-else statement)
18