Hi,
I am facing this strange NULL POINTER EXCEPTION phenomenon.
In my programme, i have a String Variable which is populated by a method from a different java class in the same package. In order to counter a Null Pointer exception (incase the method that is being called for returns a null), i am using try catch block. Now my query is, the try catch block works perfectly if i use a IF condition as is shown below, else the try catch block is never reached. The code is :
try{
String abc = Diffclass.getString();
if(abc.equalsIgnorecase("null"))
{
SOP(" something "); //this however does not get printed even if the try catch works
}
}
catch(NullPointerException ex)
{
SOP;
Continue;
}
if i remove/comment the IF condition the try-catch block is not executed.
am i missing something important here and so i find this strange ? or what is actually happening.