I'm confused about Type wrappers being immutable when executing following code
static void inc(Integer nr)
{
System.out.printf("1. inc() \t %d \n", nr);
nr++;
System.out.printf("2. inc() \t %d \n", nr);
} // inc()
public static void main(String[] args)
{
Integer nr1 = 10;
System.out.printf("a. main() \t %d \n", nr1);
inc(nr1);
System.out.printf("b. main() \t %d \n", nr1);
} // main()
Executing it creates following output
a. main() 10
1. inc() 10
2. inc() 11
b. main() 10
If a type wrapper is immutable, why then is the value increased between line "1. inc" and "2. inc" and does line "b. main" print the same value as "1. main"?
thank you
Chris