class Biodata {
String nama;
int umur;
static void tampil() {
System.out.println(“Nama saya ” + nama + "\n");
System.out.println(“Umur saya ” + umur + “tahun”);
}
}
class Show {
public static void main (String [] args) {
Biodata.nama = “Elita”;
Biodata.umur = 19;
Biodata.tampil();
}
}
OUTPUT ::
Nama saya Elita
Umur saya 19 tahun
Minggu, 27 September 2009
JAVA = BREAK
class Break {
public static void main(String[] args) {
int i,j;
nyo:
for (i = 0; i < 3; i++) {
for(j=0 ; j < 3; j++){
System.out.println("I = " + i +", J = " + j + "PRINCE TARO");
if (j==1) break nyo;
}
}
System.out.println("\nKAKKOI !!");
}
}
Output :
I = 0, J=0 PRINCE TARO
I = 0, J=1 PRINCE TARO
KAKKOI !!
public static void main(String[] args) {
int i,j;
nyo:
for (i = 0; i < 3; i++) {
for(j=0 ; j < 3; j++){
System.out.println("I = " + i +", J = " + j + "PRINCE TARO");
if (j==1) break nyo;
}
}
System.out.println("\nKAKKOI !!");
}
}
Output :
I = 0, J=0 PRINCE TARO
I = 0, J=1 PRINCE TARO
KAKKOI !!
JAVA = CLASS
KODING 1 ::
class Michael {
private int a=29;
public void info() {
System.out.println("nilai a = "+ a + "\n");
System.out.println("Dipanggil pada = " + this.getClass().getName());
}
}
===============================================================================
KODING 2 ::
class Jackson extends Michael {
private int b=14;
public static void main(String[] args) {
Jackson obj = new Jackson();
obj.info();
System.out.println("");
}
}
OUTPUT ::
class Michael {
private int a=29;
public void info() {
System.out.println("nilai a = "+ a + "\n");
System.out.println("Dipanggil pada = " + this.getClass().getName());
}
}
===============================================================================
KODING 2 ::
class Jackson extends Michael {
private int b=14;
public static void main(String[] args) {
Jackson obj = new Jackson();
obj.info();
System.out.println("");
}
}
OUTPUT ::
JAVA = RETURN
public class Main {
public static int x, y;
public static long loong;
public static String mystr;
public static void myProc()
{
byte i;
boolean b;
i = 5;
b = i==7;
}
public static int myFunc()
{
return x*y;
}
public static void main(String[] args)
{
System.out.println("How are you?");
x = 4; y = 5;
System.out.println("myFunc is "+myFunc());
}
}
OUTPUT ::
public static int x, y;
public static long loong;
public static String mystr;
public static void myProc()
{
byte i;
boolean b;
i = 5;
b = i==7;
}
public static int myFunc()
{
return x*y;
}
public static void main(String[] args)
{
System.out.println("How are you?");
x = 4; y = 5;
System.out.println("myFunc is "+myFunc());
}
}
OUTPUT ::