For example
public static void mapValues()
{
if(getName("Wilson") != null)
{
String name = getName("Wilson");
}
// Or just
String name = getName("Wilson");
}
private static String getName(String name) {
String returnValue = " "; // Setting default returnvalue as empty
if(name.equals("Wilson"))
{
returnValue = name;
}
return returnValue;
}
I know its not necessary to put a null check but my tech lead says it doesn't hurt you to put a null check even if not necessary. How would I make him understand its not okay?