// a class to demonstrate how primitive data and objects differ when passed as parameters public class IncrementClassUser { public static void main(String[] args) { IncrementClass foo=new IncrementClass(0); int x=0; increment(foo); // foo, being an object, can (and will change) increment(x); // x, being an instance datum, will not change here (but the parameter in increment will change) System.out.println(foo.getValue( )); System.out.println(x); } public static void increment(int value) { // value changes, but x does not value++; } public static void increment(IncrementClass foo) { // foo does change foo.inc(); } }