I don't feel satisfied with avoiding null in OOP. Is there an alternative solution? I do not like to avoid this this way .
What is the best way to handle this?
Java 8 has a new Optional type, which I think you are asking about
Optional
A container object that may or may not contain a nonzero value. If a value is present, isPresent() will return true and get() will return a value.
isPresent()
get()
Although you don't like it, Null Object Pattern is one of the best ways to avoid a null value. Also never return null when you can return an empty list.
I want to add a property of the static class Empty. This returns a specific value for an object that can be compared to - like string.Empty in .NET
Source: https://habr.com/ru/post/979381/More articles:Rearrange Sphinx variables in code blocks - variablesConvert CSV file contents to dictionary - functionSphinx permutations next to angle brackets - pythonHow to access remember_token virtual attribute in integration test? - ruby-on-railsWhy is UTF-8 text sorted in a different order between OS X and Linux? - sortingadd white border to UIImage - iosWhat does _ (underscore) mean in Spock tests? - testingHow to draw a colored frame around NSImage? - cocoaHow to trigger data validation for all controls? - validationAttributeError: cannot set attribute - pythonAll Articles