Skip to content

Instantly share code, notes, and snippets.

@ardianta
Created October 17, 2015 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ardianta/953a4b60b6677c6060e7 to your computer and use it in GitHub Desktop.
Save ardianta/953a4b60b6677c6060e7 to your computer and use it in GitHub Desktop.
Demo operator pembanding di java
package pertemuan3;
public class OperatorPembanding {
public static void main(String[] args) {
int nilaiA = 12;
int nilaiB = 4;
boolean hasil;
// apakah A lebih besar dari B?
hasil = nilaiA > nilaiB;
System.out.println(hasil);
// apakah A lebih kecil dari B?
hasil = nilaiA < nilaiB;
System.out.println(hasil);
// apakah A lebih besar samadengan B?
hasil = nilaiA >= nilaiB;
System.out.println(hasil);
// apakah A lebih kecil samadengan B?
hasil = nilaiA <= nilaiB;
System.out.println(hasil);
// apakah nilai A sama dengan B?
hasil = nilaiA == nilaiB;
System.out.println(hasil);
// apakah nilai A tidak samadengan B?
hasil = nilaiA != nilaiB;
System.out.println(hasil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment