Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecated Short(String) how to update?

I'm handling this problem:

produto.setQuantidade(new Short("7"));

Short appears deprecated with a mark. How can I update this for above Java 9 versions? (Now, I have Java 11)

like image 406
Marcel Motta Avatar asked Mar 16 '26 18:03

Marcel Motta


1 Answers

You shall use Short.valueOf. This is taken from the javadoc

Deprecated. It is rarely appropriate to use this constructor. The static factory valueOf(short) is generally a better choice, as it is likely to yield significantly better space and time performance

Note: The public constructor is up forRemoval starting Java-16.

like image 159
kucing_terbang Avatar answered Mar 19 '26 07:03

kucing_terbang