/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main
( String[] args
){ Dog aDog = new Dog("Max");
foo(aDog);
if (aDog.getName().equals("Max")) { //true
System.
out.
println( "Java passes by value." );
} else if (aDog.getName().equals("Fifi")) {
System.
out.
println( "Java passes by reference." ); }
}
public static void foo(Dog d) {
d.getName().equals("Max"); // true
d = new Dog("Fifi");
d.getName().equals("Fifi"); // true
}
}
class Dog{
this.name = name;
}
return this.name;
}
public void setName
(String name
){ this.name = name;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKCBTdHJpbmdbXSBhcmdzICl7CiAgICBEb2cgYURvZyA9IG5ldyBEb2coIk1heCIpOwogICAgZm9vKGFEb2cpOwoKICAgIGlmIChhRG9nLmdldE5hbWUoKS5lcXVhbHMoIk1heCIpKSB7IC8vdHJ1ZQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbiggIkphdmEgcGFzc2VzIGJ5IHZhbHVlLiIgKTsKCiAgICB9IGVsc2UgaWYgKGFEb2cuZ2V0TmFtZSgpLmVxdWFscygiRmlmaSIpKSB7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCAiSmF2YSBwYXNzZXMgYnkgcmVmZXJlbmNlLiIgKTsKICAgIH0KfQoKcHVibGljIHN0YXRpYyB2b2lkIGZvbyhEb2cgZCkgewogICAgZC5nZXROYW1lKCkuZXF1YWxzKCJNYXgiKTsgLy8gdH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