What you are looking for is known as Autoboxing. This Oracle tutorial should shed some light on the matter.
Wrapper class object as a return type
-
14-06-2023 - |
Question
It's a very simple question which I could not understand. I am still a beginner in Java.
Consider a example:
public Integer function() {
int i=1;
return i;
}
The return type is an Integer
type and I am returning a primitive
type. It is allowed by the compiler.
So the question is, how that conversion(primitive to wrapper) takes place.
I am using JDK 1.7
.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow