Readable Code - Remove Checking null
Readable Code – Checking NULLWe must have come across these lines of code many times
//JAVA
bool func(String name)
{
if ( (name != null) && (name.equals("true") ) {
...
} else {
...
}
}
A better way to code this would be
//JAVA
bool func(String name)
{
if ( "true".equals(name) ) {
...
} else {
...
}
}
Labels: Java, readable code
About this entry
You’re currently reading “
- Published:
- 8:36 pm
- by -
0 Comments (Post a Comment)