Hi!
What will be the result of attempting to compile and run the following class?
public class TestClass
{
public static void main(
String args[ ] )
{
int i = 1;
int[] iArr = {1};
incr(i) ;
incr(iArr) ;
System.out.println( "i = " + i + " iArr[0] = " + iArr [ 0 ] ) ;
}
public static void incr(int n ) { n++ ; }
public static void incr(int[ ] n ) { n [ 0 ]++ ; }
}
I think that iArr[0] = 1 but the code will print i = 1 iArr[0] = 2. Why?
Thank you in advance.