WithoutBook Forum
Ques. how to handle null pointer exception?
- how to handle null pointer exception
Posted on Oct 01, 2012 by madan
Ans. Either you need to catch the exception by using try catch block or you need to check whether the object is null wherever you think the object can be null.
Option 1:
try{
-----code-----
}catch(Exception e){
}
Option 2:
if(obj != null){
-----do the needful-----
}
Option 1:
try{
-----code-----
}catch(Exception e){
}
Option 2:
if(obj != null){
-----do the needful-----
}
Posted on Nov 06, 2012 by Arindam
Ans. Either you need to catch the exception by using try catch block or you need to check whether the object is null wherever you think the object can be null.
Option 1:
try{
-----code-----
}catch(Exception e){
}
Option 2:
if(obj != null){
-----do the needful-----
}
Option 1:
try{
-----code-----
}catch(Exception e){
}
Option 2:
if(obj != null){
-----do the needful-----
}
Posted on Nov 06, 2012 by Arindam