implementasi operator "?"
Sebelumnya sudah pernah ane share tentang operator "?". kalo saudara - saudara semua belum baca silahkan klik di sini untuk mempelajarinya.
langsung saja, berikut source codenya
>>>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author pradikta
*/
public class operator1 {
public static void main(String[]okky){
int nomor = (int)(Math.random()*7);
String str = (nomor == 0)? "Hari Libur" : "Hari Kerja";
System.out.println("Nomor = "+nomor);
System.out.println("Keterangan = "+ str);
}
}
langsung saja, berikut source codenya
>>>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author pradikta
*/
public class operator1 {
public static void main(String[]okky){
int nomor = (int)(Math.random()*7);
String str = (nomor == 0)? "Hari Libur" : "Hari Kerja";
System.out.println("Nomor = "+nomor);
System.out.println("Keterangan = "+ str);
}
}
Comments
Post a Comment