data structures leon andretti abdillah - wordpress.com · 9 leon andretti abdillah, data...

26
02 Basic Java with eClipse Data Structures Leon Andretti Abdillah

Upload: dohuong

Post on 11-Aug-2019

237 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

02

Basic Java with eClipse

Data Structures

Leon Andretti Abdillah

Page 2: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Preparation

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P2

1. Java Development Kit (JDK) versi 1.6 keatas.Java Development Kit merupakan perangkat lunak yang digunakan untuk melakukan proses kompilasi dari kode java menjadi bytecode yang dapat dimengerti dan dapat dijalankan oleh java runtime environtment.

2. Java Runtime Environtment (JRE)

Java Runtime Environtment merupakan perangkat lunak yang digunakan untuk menjalankan aplikasi yang dibangun menggunakan java. Versi JRE harus sama atau lebih tinggi dari JDK yang digunakan untuk membangun aplikasi agar aplikasi dapat berjalan sesuai dengan yang diharapkan.

3. eClipse (juno)merupakan Java (Integrated Development Environment) IDE yang dikembangkan oleh IBM dan pada 2001 menjadi nonprofit EclipseFoundation (www.eclipse.org) untuk mengelola sebagai suatu open-source platform.

Page 3: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Run eclipse

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P3

Click Icon eClipse

Page 4: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Eclipse ide (Integrated Development

Environment)

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P4

Page 5: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Create new java project

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P5

File | New | Java Project

Page 6: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P6

Pada Project name, ketikkan

Algo

Page 7: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

New Java Project

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P7

New Java Project = Algo

Page 8: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Create new package

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P8

Pada scr di Algo,

klik kanan dan pilih

Scr | New |

Package

Page 9: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Create new package

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P9

Definition: A package is a grouping of related types providing access protection

and name space management. Note that types refers to classes, interfaces,

enumerations, and annotation types. Enumerations and annotation types are

special kinds of classes and interfaces, respectively, so types are often referred to

in this lesson simply as classes and interfaces.

A package is a namespace that organizes a set of related classes and interfaces.

Conceptually you can think of packages as being similar to different folders on

your computer.

You might keep HTML pages in one folder, images in another, and scripts or

applications in yet another. Because software written in the Java programming

language can be composed of hundreds or thousands of individual classes, it

makes sense to keep things organized by placing related classes and interfaces

into packages.

Page 10: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Create new package

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P10

Page 11: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

new package = Package01

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P11

Type Name =

package01

Page 12: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P12

Page 13: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Create new class

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P13

package01 | New | Class

Page 14: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

New class = hello

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P14

New Class = Hello

Page 15: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P15

Page 16: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P16

package Package01;

public class Hello {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

}

}

Page 17: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P17

package Package01;

public class Hello {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.print("Hello");

System.out.print("-----");

System.out.print("Nama : Jokowi");

System.out.print("NIM : 12142001");

System.out.print("Kelas: TI1A");

System.out.print("-----");

}

}

Page 18: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Running the program

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P18

Click the green arrow at the top of the window to run the

program.

Page 19: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P19

Page 20: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P20

Page 21: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P21

package Package01;

public class Hello {

/**

* @param args

*/

public static void main(String[] args) {// TODO Auto-generated method stub

System.out.print("Hello \n");

System.out.print("----- \n");

System.out.print("Nama : Jokowi \n");

System.out.print("NIM : 12142001\n");

System.out.println("Kelas: TI1A ");

System.out.print("-----\n");

}

}

Page 22: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P22

Page 23: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Notes

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P23

Nama file harus sama dengan nama kelas program. Misal pada

kode diatas nama kelasnya adalah Hello, maka nama file

harus Hello.java

Hanya boleh terdapat satu kelas public pada sebuah file

Kelas yang menjadi program harus memiliki metode public static void main(String[] args)

Terminal pada java menggunakan tanda ; (titik koma).

Page 24: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Escape Sequences

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P24

Escape Sequence Name Description

\a Bell (alert)Makes a sound from the computer

\b Backspace Takes the cursor back

\t Horizontal TabTakes the cursor to the next tab stop

\n New lineTakes the cursor to the beginning of the next line

\v Vertical Tab Performs a vertical tab

\f Form feed

\r Carriage return Causes a carriage return

\" Double QuoteDisplays a quotation mark (")

\' Apostrophe Displays an apostrophe (')

\? Question mark Displays a question mark

\\ Backslash Displays a backslash (\)

\0 Null Displays a null character

Page 25: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Getting input from keyboard

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P25

???

Page 26: Data Structures Leon Andretti Abdillah - WordPress.com · 9 Leon Andretti Abdillah, Data Structures, Review A&P 20/03/2013 Definition: A package is a grouping of related types providing

Home work

20/03/2013Leon Andretti Abdillah, Data Structures, Review A&P26

Please read

If then else

Switch

For

While

Do while

Prepare a group consist of 6-8 students

Each student should have at least one blog (blogger/blogspot

or wordpress); note: the blog name must beyour real name

combine with nim