This foo
that is returned by lookup
could be null
.
That's why I'm trying to avoid calling foo.getFooStr()
on a null
value by first returning null
if foo
is null
.
But is there a better (more concise) way to write this?
public static String getFooStr(String input)
{
Foo foo = lookup(input);
if(foo==null)
{
return null;
}
return foo.getFooStr();
}