Whether I pass primitives or objects the original value does not change. Is this expected result?
Java Code:
public class Class {
public static void main(String args[])
{
int x=3;
doItPrim(x);
System.out.println(x);//3
Integer i=new Integer(3);
doItObj(i);
System.out.println(i);//3
}
public static void doItPrim(int x)
{
x=5;
}
public static void doItObj(int i)
{
i=new Integer(5);
}
}
No comments:
Post a Comment