Created
November 30, 2016 03:02
-
-
Save dhanyn10/8e66cb9ce750a0d9e2d6ff7d02c64b0e to your computer and use it in GitHub Desktop.
Berikut ini contoh code sederhana yang mendemonstrasikan program yang menggunakan tipe data boolean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ujiboolean1 { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
boolean a, b; | |
//perrnyataan benar | |
a = true; | |
System.out.println("nilai a = " + a); | |
if (a) { | |
System.out.println("pernyataan ke 1 dieksekusi"); | |
} | |
if (!a) { | |
System.out.println("pernyataan ke 2 dieksekusi"); | |
} | |
//pernyataan salah | |
b = false; | |
System.out.println("nilai b = " + b); | |
if (b) { | |
System.out.println("pernyataan ke 3 dieksekusi"); | |
} | |
if (!b) { | |
System.out.println("pernyataan ke 4 dieksekusi"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment