Resepi Puding Laici
Rabu, 22 April 2009
Resepi Puding Laici Kak Nun Propa
Posted by Tulis Tangan at 4:44 PTG 4 comments
Ahad, 19 April 2009
Aku Dan Puding Laici
Puding Laici
Posted by Tulis Tangan at 2:00 PTG 3 comments
Sabtu, 11 April 2009
Aku dibius Jiwang
Dalam dua entry yg lepas, aku dgn hati yg senang telah menerbitkan artikel berkenaan bahasa pengaturcaraan java. Byk juga pendapat2 yg diberikan. Ada yg begitu teruja dan ada yang mencadangkan aku mengketegorikan java di tempat lain. Dalam kesempatan ini, aku nak celoteh kat korang semua, artikel2 berkenaan java tu aku akan selitkan dalam setiap post yg aku akan terbitkan. Jadi jgn la pk aku nak ubah blog ni kepada kelas belajar Java.Hehehehe..
Posted by Tulis Tangan at 11:42 PTG 3 comments
Isnin, 6 April 2009
Guna Bit ngan Bitwise Operator
Hi, Bertemu lagi dalam rancangan, mari belajar programming. Ok, aku nak bagi satu common stuation la kat korang. Kata la korang ada satu apps ni yg nak store kalau user tu click hari ke apa2 la. Dan menda ni korang nak simpan la dalam database. So korang nak buat mcm mana? Ada byk cara nak buat. Sure korang lagi expert la nak buat mcm mana kan. Tapi aku nak introduce satu menda kat korang la. Bg yg dah tahu tu, sila la bg penerangan kat bawah ni.
- Aku nak pakai bitmap untuk represent hari2 tu.
- So, tiap kali di pilih tarikh aku akan add dalam bitmap tu.
- Then nilai akhir bitmap aku simpan dalam database. Kira integer so kecik je la.
public class YaminBelajar {public static final int SUNDAY = 0x0001; //1public static final int MONDAY = 0x0002; //2public static final int TUESDAY = 0x0004; //4public static final int WEDNESDAY = 0x0010; //16public static final int THURSDAY = 0x0020; //32public static final int FRIDAY = 0x0040; //64public static final int SATURDAY = 0x0080; //128int dayOfWeek = 0;public static final String[] days = {"SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"};public static void main(String args[]){YaminBelajar yb = new YaminBelajar();System.out.println(" & AND operator");System.out.println("Days = " + yb.addDays(days));yb.viewDays();}public int addDays(String[] days){for(String day : days){if(day.equals("SUNDAY")){dayOfWeek = SUNDAY;System.out.println("dayOfWeek = " + dayOfWeek);}if(day.equals("MONDAY")){dayOfWeek = dayOfWeek | MONDAY;System.out.println("dayOfWeek = " + dayOfWeek);}if(day.equals("TUESDAY")){dayOfWeek = dayOfWeek | TUESDAY;System.out.println("dayOfWeek = " + dayOfWeek);}if(day.equals("WEDNESDAY")){dayOfWeek = dayOfWeek | WEDNESDAY;System.out.println("dayOfWeek = " + dayOfWeek);}if(day.equals("THURSDAY")){dayOfWeek = dayOfWeek | THURSDAY;System.out.println("dayOfWeek = " + dayOfWeek);}if(day.equals("FRIDAY")){dayOfWeek = dayOfWeek | FRIDAY;System.out.println("dayOfWeek = " + dayOfWeek);}if(day.equals("SATURDAY")){dayOfWeek = dayOfWeek | SATURDAY;System.out.println("dayOfWeek = " + dayOfWeek);}}return dayOfWeek;}public void viewDays(){if (isDayOfWeek(dayOfWeek, SUNDAY)) {System.out.println("Days = SUNDAY");}if (isDayOfWeek(dayOfWeek, MONDAY)) {System.out.println("Days = MONDAY");}if (isDayOfWeek(dayOfWeek, TUESDAY)) {System.out.println("Days = TUESDAY");}if (isDayOfWeek(dayOfWeek, WEDNESDAY)) {System.out.println("Days = WEDNESDAY");}if (isDayOfWeek(dayOfWeek, THURSDAY)) {System.out.println("Days = THURSDAY");}if (isDayOfWeek(dayOfWeek, FRIDAY)) {System.out.println("Days = FRIDAY" );}if (isDayOfWeek(dayOfWeek, SATURDAY)) {System.out.println("Days = SATURDAY" );}}public static boolean isDayOfWeek(int days, int day) {int x = days & day;System.out.println("x = " + x +" which is "+ ((days & day) == day));return (days & day) == day;}}
- & - bitwise AND operation
- | - bitwise inclusive OR operation
Labels: Java
Posted by Tulis Tangan at 8:15 PTG 4 comments
Continue vs Break
Pengetahuan AM tentang Continue dan Break
continue;Continue ni kita guna dalam loop, tak kira la la for ker while ke do...while ker.. Apa2 je la yg korang suka. Bila kita letak statement continue ni. Dia akan stop excute code selepas nya tapi aku teruskan ngan loop lagi. So dalam bahasa mudah nya dia akan stop execute code selepas dia tapi continue ngan loop. So namapak tak lagi apa aku nak bgtau. Ayat tu dah jelas dah tu.
for (int i=1;i<10;i++){if (i == 5){System.out.println("Pasal i = 5 so aku nak dia stop kat sini tapi continue loop");continue;}System.out.println("Nilai i skrg ni: " + i);}
Nilai i skrg ni: 1Nilai i skrg ni: 2Nilai i skrg ni: 3Nilai i skrg ni: 4Pasal i = 5 so aku nak dia stop kat sini tapi continue loopNilai i skrg ni: 6Nilai i skrg ni: 7Nilai i skrg ni: 8Nilai i skrg ni: 9
break;Break ni perkara yg selalu la korang guna. So cerita byk pun tak guna. Tgk la contoh coding ni. Kompem korang pahang la.
for (int i=1;i<10;i++){if (i == 5){System.out.println("Pasal i = 5 so aku nak dia stop kat sini dan kuar loop");break;}System.out.println("Nilai i skrg ni: " + i);}
Nilai i skrg ni: 1Nilai i skrg ni: 2Nilai i skrg ni: 3Nilai i skrg ni: 4Pasal i = 5 so aku nak dia stop kat sini dan kuar loop
Labels: Java
Posted by Tulis Tangan at 12:28 PTG 0 comments
Pak Najib
Pembaca sekalian, seperti yang anda sedia maklum, kepeimpinan negara telah bertukar pada beberapa hari yang lepas. Pak Lah telah menyerah kuasa secara beradab dan beradat kepada Pak Najib. Kini, Pak Najib telah menjadi PM kita yang ke enam.
Posted by Tulis Tangan at 9:48 PG 0 comments