// Johnsjava.webs.com public class Logic { public static void main(String[] args) { forLoops(); } public static void booleans() { boolean t = true; boolean f = false; boolean nt = !t; boolean and = (t && f); //false boolean or = (t || f); //true System.out.println(t); System.out.println(f); System.out.println(nt); System.out.println("and: " + and); System.out.println("or: " + or); int a = 4; int b = 3; int c = 1; boolean aIsBiggest = (a > b) && (a > c); // > // < // >= // <= // == System.out.println(aIsBiggest); } public static void ifStatements() { int a = 8, b = 5, c = 7; boolean t = false; if(t) System.out.println("True"); else System.out.println("False"); if((a < b) && (a < c)) { System.out.println("A is the smallest:"); System.out.println(a); } else if((a < b) || (a < c)) { System.out.println("A is in the middle:"); System.out.println(a); } else System.out.println("A is the largest"); } public static void whileLoops() { int i = 20; while(i < 10) { System.out.println(i); i++; } } public static void forLoops() { boolean b = true; for(int i = 0;b; i++) { System.out.println(i); b = i < 10; } int i; for(i = 0; i < 10; i++) { System.out.println(i); } } public static void doWhileLoops() { int i = 20; do { System.out.println(i); i++; }while(i < 10); } }