/** * Name: John Doe * Course: CSCI 241 - Computer Science I * Section: 001 or 002 * Assignment: 1 * * Project/Class Description * Demonstrates dangling else problem * * Known Bugs: maybe??? */ public class DanglingElse { public static void main (String [] args) { int x = 5; int y = 9; int z = 4; // the else belongs to the nearest if, which is not the one // that the indentation implies if (x < y) System.out.println("x is less than y"); if (x < z) System.out.println("x is also < z"); else System.out.println("x is not < y"); } }