openthink labs training : diving into java, breaking the surface

19
#1 Day #1 Breaking the Surface A Quick Dip Wildan Maulana [email protected] http://training.openthinklabs.com/

Upload: wildan-maulana

Post on 17-May-2015

561 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: OpenThink Labs Training : Diving into Java, Breaking the Surface

#1

Day #1

Breaking the Surface

A Quick Dip

Wildan [email protected]

http://training.openthinklabs.com/

Page 2: OpenThink Labs Training : Diving into Java, Breaking the Surface

Come on, the water'sgreat! We'll dive right in and

write some code, then compile andrun it. We're talking syntax, loopingand branching, and a look at what

makes Java so cool. You'll becoding in no time.

Page 3: OpenThink Labs Training : Diving into Java, Breaking the Surface

The Way Java Works

Page 4: OpenThink Labs Training : Diving into Java, Breaking the Surface

What you'll do in Java

Page 5: OpenThink Labs Training : Diving into Java, Breaking the Surface

Avery brief history of Java

Page 6: OpenThink Labs Training : Diving into Java, Breaking the Surface

Look how easy Itis to write Java.

int size = 27;String name = UFido";Dog rnyDog = new Dog(name, size);x = size – 5 ;if (x < 15) myDog.bark(8);while (x > 3) { myDog.play();}int [ ] numList = {2,4,6,8};System. out. print (“Hello” ) ;System.out.print(“Dog: “ + name);String nurn = “8";int Z = Integar.parselnt(nurn);try { readTheFile(“myFile.txt”) ;}catch(FileNotFoundException ex) { System.out.print(“File not found.");}

Page 7: OpenThink Labs Training : Diving into Java, Breaking the Surface

Code structure in Java

Page 8: OpenThink Labs Training : Diving into Java, Breaking the Surface

Anatomy of a class

Page 9: OpenThink Labs Training : Diving into Java, Breaking the Surface

Writing a class with a main

Page 10: OpenThink Labs Training : Diving into Java, Breaking the Surface

What can you say In the main method ?

Page 11: OpenThink Labs Training : Diving into Java, Breaking the Surface

Syntax Fun

Page 12: OpenThink Labs Training : Diving into Java, Breaking the Surface

Looping and Looping and ...

Page 13: OpenThink Labs Training : Diving into Java, Breaking the Surface

Bullet Points● Statements end in a semicolon ;

● Code blocks are defined by a pair of curly braces { }

● Declare an int variable with a name and a type: int x;

● The assignment operator Is one equals sign =

● The equals operator uses two equals signs ==

● A while loop runs everything within its block (defined by curly braces) as long as the conditional test Is true.

● If the conditional test is false, the while loop code block won't run, and execution will move down to the code Immediately after the loop block.

● Put a boolean test Inside parentheses: while (x = 4) ( }

Page 14: OpenThink Labs Training : Diving into Java, Breaking the Surface

Conditional Branching

Page 15: OpenThink Labs Training : Diving into Java, Breaking the Surface

Sharpen Your Pencil

Page 16: OpenThink Labs Training : Diving into Java, Breaking the Surface

Coding a Serious Business Application

Page 17: OpenThink Labs Training : Diving into Java, Breaking the Surface

Monday Morning at Bob's

…...

Page 18: OpenThink Labs Training : Diving into Java, Breaking the Surface

Let's Write a Program