introduction to java

26
Origin of Android Android Inc. was founded by “Andy Rubin” in October 2003 GOOGLE acquired Android Inc. on August 17, 2005

Upload: hemant-shori

Post on 06-Aug-2015

100 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Introduction to java

Origin of Android

Android Inc. was founded by “Andy Rubin” in October 2003

GOOGLE acquired Android Inc. on August 17, 2005

Page 2: Introduction to java

Introduction to Android Android is a open source

(os) Platform powered by

Linux os Developed in Java and

xml

Application

LINUX Kernel

CPU Memory

Devices

Basic Fundament Of Android

Page 3: Introduction to java

TabletMobile device Android- auto

Android-TV Android-Camera

Types of Android Devices

Android-Gear

Page 4: Introduction to java

Versions

Eclair

Froyo Gingerbread

GingerbreadLollipop preview

Donut

Jelly bean

Kitkat

Honeycomb Icecreamsandwich

Name Version

Alpha 1.0

Beta 1.1

Cupcake 1.5

Donut 1.6

Eclair 2.1

Froyo 2.2

Gingerbread 2.3

Honeycomb 3.0

Icecream sandwich 4.0

Jelly bean 4.2

Kitkat 4.4

Lollipop 5.0.2

Page 5: Introduction to java

Application Development Steps

Download and Install the JDK Install Android Studio and Android SDK http://developer.android.com

Page 6: Introduction to java

Coding in android

Java -(logic) Xml-(layout)

• Java is used for dynamical changes • Xml is used for static layout

Page 7: Introduction to java

Why Java is Important

JAVA Object Oriented Programming

Two reasons : Trouble with C/C++ languages is that

they are not portable and are not platform independent languages

Emergence of World Wide Web which demanded Portability and security necessitated the invention of Java

Page 8: Introduction to java

Java is architecture-neutral

JAVA Program Execution

Page 9: Introduction to java

Structure

Class Name

Class body

Class member instancevariable

Access modifier

Class member instancemethod

Page 10: Introduction to java

Access ModifiersAccess modifiers used to set access levels for classes, variables, methods and constructors. The four access levels are:•Visible to the package. the default. No modifiers are needed•Visible to the class only (private)•Visible to the world (public)•Visible to the package and all subclasses (protected)

Page 11: Introduction to java

Hello world Program in java

Lets Get Started

public class hello {

public static void main(String [] args) { System.out.println("Hello World"); }}

Page 12: Introduction to java

How to get it running

Save the file with hello.java Why?

To compile: javac hello.java

To run: java hello

Page 13: Introduction to java

Variablespublic class hello{

public static void main(String []args) {String color;int speed;color="red";speed=150;System.out.println("color of car is "+

color);System.out.println("speed of car is

"+ speed); }}

Page 14: Introduction to java

Objectclass vehicle{

String color;int speed;

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

vehicle obj = new vehicle();obj.color ="red";obj.speed = 150;System.out.println("color of car is

"+obj.color);System.out.println("speed of car is

"+obj.speed); }}

Page 15: Introduction to java

Multiple Objectsclass vehicle{

String color; int speed;

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

vehicle obj = new vehicle();obj.color="red“; obj.speed =150;vehicle obj2 =new vehicle();obj2.color="blue“; obj2.speed =180;System.out.println("color of car is

"+obj.color+","+obj2.color); System.out.println("speed of car is "+obj.speed+","+obj2.speed); }}

Page 16: Introduction to java

Static variableclass vehicle{

static String color; static int speed;

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

vehicle obj = new vehicle();obj.color="red“; obj.speed =150;vehicle obj2 =new vehicle();obj2.color="blue“; obj2.speed =180;System.out.println("color of car is

"+obj.color+","+obj2.color); System.out.println("speed of car is "+obj.speed+","+obj2.speed); }}

Page 17: Introduction to java

Methodclass vehicle{

public void attributes(){System.out.println("hello");

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

vehicle obj = new vehicle();obj.color="red“; obj.speed =150;vehicle obj2 =new vehicle();obj2.color="blue“; obj2.speed =180;obj2.attributes();

} }

Page 18: Introduction to java

Static Methodclass vehicle{

public static void attributes(){System.out.println("hello");

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

vehicle obj = new vehicle();obj.color="red“; obj.speed =150;vehicle obj2 =new vehicle();obj2.color="blue“; obj2.speed =180; vehicle.attributes();

} }

Page 19: Introduction to java

Constructorclass vehicle{

public vehicle(){System.out.println("constructor

called");} }

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

vehicle obj = new vehicle();obj.color="red“; obj.speed =150;vehicle obj2 =new vehicle();obj2.color="blue“; obj2.speed =180;}

}

Page 20: Introduction to java

Inheritance

parent

child

class vehicle{void attributes(){

System.out.println("color of car is "+color);

System.out.println("speed of car is "+speed);} }class car extends vehicle{

String cc;public void details(){ attributes();System.out.println(“volume of car is = "+cc);

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

car maruti= new car();maruti.color = "red";maruti.speed = 150;maruti.cc= "800 cc";maruti.details();

} }

Page 21: Introduction to java

If / Elseif (logic condition) {something}else if (logic condition) { something}else {something else}

Page 22: Introduction to java

Switch switch(variable){

case(1): something;break;

case(23): something;break;

default: something;}

Page 23: Introduction to java

For loopfor ( initialization , condition , iteration){//do something}

for ( int i=0 ; i<20 ; i++ ) {System.out.println(“change in value");}

Page 24: Introduction to java

Whilewhile( condition ){//do something}

while (i<20){System.out.println(“value");i++;}

Page 25: Introduction to java

CastingCasting is the method to convert type of the variable.Class typecast{public static void main(String []args) {

int a=5;float c;c=(float)a/2; // using(float) is type

casting }}

Page 26: Introduction to java

Questions ?

Thank you