/* * Various ways, legal and not, that "if" can be written * * Created: August 2023 * @author gtowell */ public class If3 { public static void main(String[] args) { int val = Integer.parseInt(args[0]); boolean isPositive = val > 0; // this is OK, and put the comparison within parens if (val > 0) { System.out.println(val + " is positive"); } // this is OK, but VSC hates it if (val > 0) { System.out.println(val + " is positive"); } // This is Ok, but not recommended because it can cause problems later if (val>0) System.out.println(val + " is positive"); // This is NOT OK // the boolean, even when it is a straight boolean, must be within parent if isPositive { System.out.println(val + " is positive"); } } }