In this code.
public class Test { public static void testFun(String str) { if (str == null | str.length() == 0) { System.out.print
The problem here is that in your code the program is calling 'null.length()' which is not defined if the argument passed to the function is null. That's why the exception is thrown.