Thursday, 8 August 2013

Java vs Objective C in case of nullpointer exception

Java vs Objective C in case of nullpointer exception

Why does Java frequently throw null pointer exception if I try to access
null values while Objective C does not?
Java:
public class SubscribeEmailActivity {
String status;
public static void main(String[] args){
if(Status.equals(null)||status.equals(""){
// i am getting error here
}
}
}
Objective C:
//in .h file
NSString *exp;
//in .m file
if ([exp isEqualToString:NULL] ||[exp isEqualToString:@""])
{
// i am not getting any error
}

No comments:

Post a Comment