import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        f(null);
        f(false);
        f(true);
    }

    private static void f(Boolean b) {
        try {
            System.out.println(g(b) + " --unchecked--> " + (b ? "true " : "false") + " -> opposite: " + (!b ? "true " : "false"));
        } catch (Exception exception) {
            System.out.println(g(b) + " --unchecked--> " + exception);
        }
        System.out.println(g(b) + " --checked----> " + (b != null && b ? "true " : "false") + " -> opposite: " + (b == null || !b ? "true " : "false"));
    }

    private static String g(Boolean b) {
        return String.format("[%-5s]", String.valueOf(b));
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: