replacing null declaration with Optional java -


i'm having hard time understanding of optional class. so, have task need replace every null initialization optional class.

e.g.

i have class client

so made object this:

client chosen = null;

how supposed replace null initialization optional?

your initialization following:

optional<client> chosen = optional.empty();  

or if want assign initial value:

client client = new client(); optional<client> chosen = optional.of(client);  

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -