What is the best situation to remove deprecated functions dependency from Java 11

user_3093890 :

I am upgrading my application to support java 11. When should I remove the deprecated functions like new Integer(String)?

There are some places where our application used statement like Integer iVar = new Integer("1") in my code, which is showing as deprecated in Java 11. Is it the best time to remove the deprecated code now itself or can we wait for sometime

Basically, I need some help when these type of code could be completely removed from Java

Dorian Gray :

It is completly safe to remove the function in your example. Reading the docs says:

Deprecated. It is rarely appropriate to use this constructor. Use parseInt(String) to convert a string to a int primitive, or use valueOf(String) to convert a string to an Integer object.

In your example: Integer iVar = Integer.valueOf("1")

There is really no point to create a new instance of Integer every time.

In each case of a deprecated method, you have to read the documentation and look for the replacements. Better sooner than later.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=115612&siteId=1