Should a retrieval method return ‘null’ or throw an exception when it can’t produce the return value? [closed]

I am using java language,I have a method that is supposed to return an object if it is found.

If it is not found, should I:

  1. return null
  2. throw an exception
  3. other

Which is the best practise or idiom?

36 s
36

Leave a Comment