Java essentials for hadoop

22
Java Essentials for Hadoop

description

java for hadoop from #easylearning guru ,we provide online class for hadoop and witch will required knowledge of java ,so we provide java training class for student

Transcript of Java essentials for hadoop

Page 1: Java essentials for hadoop

Java Essentials for Hadoop

Page 2: Java essentials for hadoop

Agenda

What is Java ?Features of JavaHow Java WorksJava Data TypesJava OperatorsStatements & Blocks in JavaJava Class Java Basic ConstructsCreating an ObjectArrays

Page 3: Java essentials for hadoop

What is Java ?

Java is a high level programming language developed by Sun Microsystems and released in November 1995.

Java can be used to create complete applications that may run on a single computer or be distributed among servers and clients in a network.

Java is Object-Oriented and follows the principal of “write once run anywhere” codes.

Page 4: Java essentials for hadoop

Features of Java

Simple

Object Oriented

Multithreaded

Distributed

Platform Independent

Secure

Robust

Page 5: Java essentials for hadoop

What is JDK and JRE ?

JDK

+

Development tools

Compiler Debugger

JRE

JVMUtility

Classes

Page 6: Java essentials for hadoop

How Java Works ?

Source Code

Byte Code

JVM

JIT Compiler

Java Interpreter

Runtime System

Output of the

program

Java Compiler

Hexadecimal format

It is used to speed up the execution

Converts total byte code into machine code

Page 7: Java essentials for hadoop

Data Types

Data Type Size Default value

Boolean 1 bit False

char 2 bytes '\u0000'

byte 1 byte 0

short 2 bytes 0

int 4 bytes 0

long 8 bytes 0L

float 4 bytes 0.0f

double 8 bytes 0.0d

String(any object) - null

Primitive Data TypesNon-primitive Data Types

(Reference type)

1. Class Type2. Interface Type3. Array type

Page 8: Java essentials for hadoop

Operators

Provide a way to perform different operations on variables.

Operator Type operators

Assignment =

Arithmetic + , - , * , /

Relational < , > , <= , >= , == , !=

Logical && , || , !

Bitwise &, |, ^, >>, <<

Unary ++ , --, +, -, !

Page 9: Java essentials for hadoop

Statements & Blocks in JAVA

Statements are always terminated by a semi-colon(;)

A block is a compound statement enclosed in curly

brackets.

Statement forms a complete command to be executed.

class Stat{Boolean flag ; //statement 1Int x = 20 ; //Statement 2..

}

Open braces for a block

End of block, using close braces

Page 10: Java essentials for hadoop

A class can be defined as a template/blue print that describes the behaviors and states that object of its type support.

Objects have states and behaviors. Example: Bicycles have state (current gear, current pedal cadence, two wheels, number of gears) and behavior (braking, accelerating, slowing down, changing gears).

An object is an instance of a class.

Java Class

Page 11: Java essentials for hadoop

Example of a class

public class hello {public static void main(String[] args)

{int number = 10; //variableSystem.out.println("Hello");System.out.println(number);

}}

class Myclass{

//data members//constructors

// methods or member functions}

Page 12: Java essentials for hadoop

Method

Public static void myFunction(arg1, arg2, arg3){

}

Modifier

Java keyword

return type

function name

Any number of arguments

//Body of the method

Page 13: Java essentials for hadoop

Public• Can be accessed from anywhere.

Protected

• Can be accessed in the same package or any derived class.

Default

• Can be accessed within the class only. Private

• Can be accessed within the same package.

Modifiers

Page 14: Java essentials for hadoop

Java Basic Constructs

If…else case

Switch Case

Loops in Java – for loop, while loop, do while loop

Page 15: Java essentials for hadoop

If Else - Syntax

If (condition){

Statements }

else{

Statements}

Statementstrue

false

condition

Page 16: Java essentials for hadoop

Switch - Syntax

Switch(x){

Case 1:Statements

Case 2:Statements

default :Statements

}

Case 1

Statements

Statements

Case 2

true

false

true

false

default

End of the switch Statement

Page 17: Java essentials for hadoop

For Loop - Syntax

for (initialization; condition; increment/decrement;)

{statement 1;

statement 2; …

}

Initialization

Inside the for looptrue

false

Increment/decrement

End of for loop

condition

Page 18: Java essentials for hadoop

While Loop - Syntax

while (<condition>) {

statement1;…

}

Initialization

Inside the for looptrue

false

Increment/decrement

End of for loop

condition

Page 19: Java essentials for hadoop

Do While Loop Syntax

do {

statement 1;statement 2;……

} while (<condition>) ;

Initialization

Inside the do while loop

true

false

Increment/decrement

End of for loop

condition

condition

Page 20: Java essentials for hadoop

Creation of the Object

Class_name object_name = new class_name();

Name of the class

Creates a reference object

Allocate memory

Constructor of the class

Creates a new object

Page 21: Java essentials for hadoop

An array is a list of similar elements. An array has a fixed:

- name- type- length

These must be declared when the array is created. Array size cannot be changed during the execution

of the code.

Arrays

Page 22: Java essentials for hadoop