In this code we have an int where we initialized with a value. Now we making this reference to another variable and assign a new value. But this should be reflected in other variable. But it does not. How this java reference is passed by value. Strings are immutable but how this happens in integer
public class Confusedwithintegerandstrings
{
public static void main(String[] args)
{
int a=10;
int c=a;
System.out.println(c);
a=20;
System.out.println(a);
System.out.println(c);
}
}
this is O/P
10
20
10