- Use carefully Boolean in setter method for boolean attribute:
DON'T DO THIS (throws null pointer exception):
public
 class BooleanMethod {
* 
@return the attribute
*/
}
* 
@param attribute the attribute to set
*/
}
BooleanMethod obj = 
new BooleanMethod();
Boolean condition = 
null;
obj.setAttribute(condition);
System.
out.println(obj.isAttribute());
}
Exception in thread "main" 
java.lang.NullPointerExceptionat BooleanMethod.main(BooleanMethod.java:23)BETTER
public
 class BooleanMethod {
* 
@return the attribute
*/
}
* 
@param attribute the attribute to set
*/
}
BooleanMethod obj = 
new BooleanMethod();
Boolean condition = 
null;
obj.setAttribute(condition);
}
System.
out.println(obj.isAttribute());
condition = Boolean.
TRUE;
obj.setAttribute(condition);
}
System.
out.println(obj.isAttribute());
}
