Page 27 - PowerPoint Presentation
P. 27
MENGISYTIHARKAN, MEMULAKAN DAN
1.3 1.3.4 MENETAPKAN NILAI PADA PEMBOLEH
UBAH DAN PEMALAR
• Pemboleh ubah dikenal sebagai tempat untuk menyimpan data.
• Setiap pemboleh ubah dalam Java mempunyai jenis yang tertentu yang
menentukan saiz dan susun atur memori dan set operasi yang boleh digunakan.
• Semua pemboleh ubah perlu diisytiharkan sebelum boleh digunakan.
• Pengisyiharan pemboleh ubah perlu dilaksanakan dengan memberikan jenis
data dan nama pemboleh ubah.
JENIS DATA NAMA PEMBOLEH UBAH CONTOH
public class pembolehUbah {
public static void main(String[] args {
INTEGER X int x ;
}
}
public class pembolehUbah {
public static void main(String[] args {
STRING nama String nama ;
}
}
public class pembolehUbah {
public static void main(String[] args {
DOUBLE s , t, u double s,t,u ;
}
}
public class pembolehUbah {
public static void main(String[] args {
BOOLEAN v boolean v ;
}
}
public class pembolehUbah {
public static void main(String[] args {
CHAR w char w ;
}
}
public class pembolehUbah {
public static void main(String[] args {
FLOAT y float y ;
} 27
}

