Skip to content

Instantly share code, notes, and snippets.

@OOPUniversity
Created November 9, 2015 14:37
Show Gist options
  • Save OOPUniversity/65468eabb9134a89e0e9 to your computer and use it in GitHub Desktop.
Save OOPUniversity/65468eabb9134a89e0e9 to your computer and use it in GitHub Desktop.
Demonstration code for the blog post 'If I, if I, if I, if I Didn't Love you else I'd Hate You'
/*
* Copyright (c) 2014.
*/
package main.java.com.oopuniversity.basics.conditionals;
/**
* Created by OOPUniversity on 12/2/2014.
*/
public class IfDemo {
public static void main(String[] args) {
IfDemo ifDemo = new IfDemo();
ifDemo.trueDemo();
ifDemo.falseDemo();
ifDemo.ifElseDemo();
}
void trueDemo() {
if (true) {
System.out.println("Condition was true.");
}
}
void falseDemo() {
if (false) {
System.out.println("Condition was false.");
}
}
void ifElseDemo() {
boolean condition = true;
if (condition == true) {
System.out.println("Condition was true.");
}
else {
System.out.println("Condition was false.");
}
condition = false;
if (condition == false) {
System.out.println("Condition was true.");
}
else {
System.out.println("Condition was false.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment