Reputation: 1913
guys!
How is the operator + implemented and works in Java internally in case when we add integer with Integer object?
package ru.systemres.ru;
public class Main {
public static void main(String[] args) {
Integer iOb = new Integer(10);
int a = iOb + 5;
System.out.println(a);
}
}
Is it overloaded? Can you show me some source code from jvm which works with it? Thanks!
Upvotes: 1
Views: 1146
Reputation: 2415
Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes.
During Unboxing (Object(Integer) --to--> Primitive(int))
Implicitly Integer.intValue()
is called to return int value.
Please Refer: https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html
Upvotes: 2