Berikut adalah codingannya menggunakan notepad di java
public class TestOr{
public static void main(String[]apf){
int i = 0;
int j = 10;
boolean test = false;
//Contoh ||
System.out.print ("IF Unjani")
test = (i > 10) ||(j++ > 9);
System.out.println (i);
System.out.println (j);
System.out.println (test);
//Contoh |
test = (i > 10) | (j++ > 9);
System.out.println (i);
System.out.println (j);
System.out.println (test);
}
}
jika berhasil maka akan tampil seperti ini

Sumber: Modul Praktekum Pemrograman Objek Dasar Rezki Yuniarti
public class TestOr{
public static void main(String[]apf){
int i = 0;
int j = 10;
boolean test = false;
//Contoh ||
System.out.print ("IF Unjani")
test = (i > 10) ||(j++ > 9);
System.out.println (i);
System.out.println (j);
System.out.println (test);
//Contoh |
test = (i > 10) | (j++ > 9);
System.out.println (i);
System.out.println (j);
System.out.println (test);
}
}
jika berhasil maka akan tampil seperti ini
Sumber: Modul Praktekum Pemrograman Objek Dasar Rezki Yuniarti
No comments:
Post a Comment