throw null

Nemrég összefutottam a következőhöz erősen hasonlító kódrészlettel:

} catch (final Exception e) {
	if (e != null)
		e.printStackTrace();
}

Tipikus „mitírki”-t lehet belőle készíteni, mondjuk egy ilyet:

try {
	throw null;
} catch (final Exception e) {
	if (e == null) {
		System.out.println("null");
	} else {
		System.out.println("nemnull");
	}
	System.out.println("e: " + e);
}

Eredmény hajtás után.

nemnull
e: java.lang.NullPointerException
Tartalom átvétel