Source of TestAssertions.java


  1: //TestAssertions.java
  2: 
  3: import java.util.Scanner;
  4: 
  5: public class TestAssertions
  6: {
  7:     public static void main(String args[])
  8:     {
  9:         //Assertions
 10:         //To activate assertion statements when the program runs:
 11:         //java -enableassertions TestAssertions
 12:         //or just ...
 13:         //java -ea TestAssertions
 14:         //==========
 15:         Scanner keyboard = new Scanner(System.in);
 16:         System.out.print("\nEnter a positive integer "
 17:             + "greater than or equal to 10: ");
 18:         int n;
 19:         n = keyboard.nextInt();
 20:         assert n >= 10;
 21:         //assert n >= 10 : n;
 22:         System.out.println("The value input was " + n + ".");
 23:     }
 24: }
 25: