Hey Ulf, > Hi Vitaly, > > I don't see any contract to throw an NPE: > https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#replace- > java.lang.CharSequence-java.lang.CharSequence- > > In any case, what's the reasonable of checking an argument, which is not > used in that case? > > > Am 02.03.2017 um 00:18 schrieb Vitaly Davidovich: > > Seems like a good idea. You probably want to null check 'replacement' > > before the bail out as the method is specified as throwing NPE in that case.
It is stated in the class comment. "Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown." Cheers, Christoph