Always try to test null pointer and test casting available in the code.
IF NULL, OR FAILED TO CAST, SIMPLY Printing Out Some Error Message Would Be Much Better Than The Runtime Exception thrown by JVM.