-2

I was looking through the documentation for primitive wrappers in Java.

While I understand the utility of all the extra functionality provided by the methods, I don't seem to understand how the object stores the primitive in the first place. There doesn't seem to be any primitive final int.

EDIT: I learnt that Java documentation only shows public fields and methods, and after going through source code see a private int field. Just to confirm, it's then as simple as the compiler doing autoboxing/autounboxing through the public constructor to set the value ?

Abhinav Vishak
  • 361
  • 1
  • 5
  • 17

1 Answers1

1

If you go to the source code of java.lang.Integer you will find

 private final int value;

The reason that you don't see it in the API documentation, is that private attributes and methods are not included in the documentation.

Harald Gliebe
  • 7,236
  • 3
  • 33
  • 38