Byte.decode ("10") and Byte.valueOf ("10") - what's the difference?

The Java 6 API primitive wrappers have pairs of static decode methods (String s) and an Off value (String s) . Both of them return a new object of the wrapper class class, and none of them are annotated as deprecated. Does anyone know the difference between the two? For example:

Byte b1 = Byte.decode("10");

and

Byte b2 = Byte.valueOf("10");
+3
source share
2 answers
+6

radix (hex, ) "0x", "0X" "#" hex "0" , valueOf (, 8 16) . ( "0x10" ) Of ( "10", 16). valueOf ( "0x10" ) NumberFormatException.

+4

Source: https://habr.com/ru/post/1728355/


All Articles