SELAMAT DATANG
DI WILAYAH TERITORIAL
KEKUASAAN SAYA
^_^

Rabu, 10 Oktober 2012

javajavajavajavajava

class TesTipeData { public static void main (String[] args) { byte b = 1; short s = 100; int i = 1000; long l = 10000; char c = 'a'; float f = 3.14f; double d = 3.14; boolean t =true; final double PI = 3.14; System.out.println("byte " +b); System.out.println("short " +s); System.out.println("int " +i); i =010; System.out.println("int " +i+ " octal mode"); i = 0XFF; System.out.println("int " +i+ " hexa mode"); System.out.println("long " +1); System.out.println("char " +c); System.out.println("float " +f); System.out.println("double " +d); System.out.println("boolean " +t); System.out.println("PI " +PI); } }
class TesKeputusan { public static void main (String[] args) { char jeniskelamin = 'W'; //nested if if (jeniskelamin=='L') System.out.println("Cowok"); else if (jeniskelamin=='P') System.out.println("Cewek"); else System.out.println("Banci"); //ternary System.out.println(jeniskelamin=='P'? " Dia pasti cowok." : "Dia pasti cewek"); //switch case switch (jeniskelamin) { case 'P' : System.out.println("Cowok"); break; case 'L' : System.out.println("Cewek"); break; default : System.out.println("Banci"); break; } } }
public class TesPerulangan { public static void main (String[] args) { int i; //for System.out.println("perulangan for..."); for (i=0; i<10; i++) System.out.println("perulangan ke : "+i); //while System.out.println("perulangan while..."); i=0; while (i<10) { System.out.println("perulangan ke : "+i); i++; } // do while System.out.println("perulangan do while..."); i=0; do { System.out.println("perulangan ke : "+i); i++; } while (i<10); } }

Tidak ada komentar:

Poskan Komentar

Ada kesalahan di dalam gadget ini