Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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