Source of Assertions.java


  1: //Assertions.java

  3: import java.util.Scanner;

  5: public class Assertions
  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
 17:         (
 18:             "\nEnter a positive integer "
 19:             + "greater than or equal to 10: "
 20:         );
 21:         int n;
 22:         n = keyboard.nextInt();
 23:         assert n >= 10;
 24:         //assert n >= 10 : n;
 25:         System.out.println("The value input was " + n + ".");
 26:     }
 27: }