Page 28 - PowerPoint Presentation
P. 28
MENGISYTIHARKAN, MEMULAKAN DAN
1.3 1.3.4 MENETAPKAN NILAI PADA PEMBOLEH
UBAH DAN PEMALAR
• Selepas pengisytiharan jenis dan nama pemboleh ubah, nilai kepada pemboleh
ubah boleh ditetapkan atau diumpukkan.
JENIS DATA NILAI CONTOH
public class pembolehUbah {
public static void main(String[] args {
INTEGER 10 int x = 10 ;
}
}
public class pembolehUbah {
public static void main(String[] args {
STRING hardeep String nama = “hardeep” ;
}
}
public class pembolehUbah {
s = 0.123 public static void main(String[] args {
DOUBLE t = 1.1 double s = 0.123, ,t = 1.1 ,u = s + u ;
u = s + t }
}
public class pembolehUbah {
public static void main(String[] args {
BOOLEAN true boolean v = true ;
}
}
public class pembolehUbah {
public static void main(String[] args {
CHAR y char w = ‘y’ ;
}
}
public class pembolehUbah {
public static void main(String[] args {
FLOAT 342.234f float y = 342.234f ;
} 28
}

