Contoh for statement

Introduction to Java Object Oriented Concept


Sejarah Java :

– Developed by James Gosling from Sun Microsystem and sold to Oracle in 2009.

– Agustus 1991, It was named as Oak.

– Januari 1995, Change to Java.

– Based on “Write Once, Run Anywhere (WORA)”.

– Can be run in web browser using Applet technology.

Download and install :

jdk-7u40-nb-7_3_1-windows-i586

netbeans-7.3.1-windows

Most commonly application programs in JDK(Java Development Toolkit) :

–Compiler : javac

Compiling a source code(.java) into bytecode(.class)

–Interpreter : java

Execute a bytecode (.class) as application.

– Debugger : jdb

– Applet Viewer : appletviewer

– Documentation: javadoc

– Compressor: jar

Java Runtime Environment (JRE) : A software that execute Java based application.

Java Virtual Machine (JVM) : A collection of programs to execute java byte code on any computer platform.

Java byte code : A collection of machine-specific instruction that be interpreted and executed by JVM. Its length is 1 byte per instruction.

Simple Program :

public class Welcome {

public static void main(String [] args) {

System.out.println(“Welcome to Java!”);  //pada java netbeans cara cepat buat sintaxnya : sout + tab

  }

}

 
If Else Statement example :

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package belajar.pertemuan.pkg1;

import java.util.Scanner;
/**
*
* @author Admin
*/
public class BelajarPertemuan1 {

/**
* @param args the command line arguments
*/

public static void main(String[] args) {  

System.out.println(“Welcome to Java”); 
Scanner input = new Scanner(System.in);
double radius,area;
double PI = 3.14;
System.out.println(“Radius : “);
radius = input.nextInt();
if (radius >= 0)
{
area = radius * radius * PI;
System.out.println(“The area for the circle of radius “+ radius
+ ” is ” + area);
}
else
{
System.out.println(“Negative input”);
}

// TODO code application logic here

}

_______________________________________________________________________________

Contoh if-else statement
Contoh if-else statement
Switch Case example
Switch Case example
While Statement
While Statement
Do While Statement
Do While Statement
Contoh for statement
Contoh for statement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s