Welcome to Abdul Malik Ikhsan's Blog

Contoh asosiasi dalam Java

Posted in Tutorial Java by samsonasik on August 23, 2007

class Mhs {
String nama;
int umur;
public Mhs(String n, int u) {
void display() {
System.out.print(nama+” “+umur);

class Mk {
String nama;
int sks;
public Mk(String n,int u) {
void display() {
System.out.print(” “+nama+” “+sks);
class Reg {
Mhs m;
Mk k;
public Reg(Mhs m, Mk k) {
public void display() {
public static void main(String[] a) {
Mhs m1=new Mhs(“Budi”,20);
Mhs m2=new Mhs(“Dewi”,18);
Mk k1=new Mk(“PTI”,2);
Mk k2=new Mk(“PSI”,3);
Reg r1=new Reg(m1,k1);
Reg r2=new Reg(m1,k2);
Reg r3=new Reg(m2,k1);
Reg r4=new Reg(m2,k2);

sumber : Pak Tedjo Darmanto.

2 Responses

Subscribe to comments with RSS.

  1. tita abc said, on August 24, 2009 at 2:50 pm

    tidak sesuai dengan yg tak cari .

  2. fachrulpbm said, on November 15, 2015 at 11:42 am

    Sulit dipercaya, ternyata ane mencari materi di tahun 2007 😀
    Thanks gan udah share hehe

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: