Quote (MexG @ Nov 4 2017 04:45am)
if you don't check if str is not null you can get a nullpointerException at str.lenght()
you should do :
if(str != null && str.length() > 5) {
That is completely unnecessary imho. Let it throw a NPE and add that to the javadoc.
If your method is getting passed null parameters there are likely issues in the invoking method. Checking for NPE everywhere makes code look horrible and it doesn't fix the problem. There is likely a problem in the calling class if you're passing null.