/* 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
{
{
SomeObject obj1 = new SomeObject(1, "Lorem ipsum");
SomeObject obj2 = (SomeObject) obj1.clone();
System.
out.
println("Object 1: " + obj1
); System.
out.
println("Object 2: " + obj2
);
System.
out.
println("São iguais? " + obj1.
equals(obj2
)); }
}
private int identifier;
private String someDescription
;
public SomeObject() {
}
@Override
// TODO Auto-generated method stub
return super.clone();
}
public SomeObject
(int identifier,
String someDescription
) { super();
this.identifier = identifier;
this.someDescription = someDescription;
}
public int getIdentifier() {
return identifier;
}
public void setIdentifier(int identifier) {
this.identifier = identifier;
}
public String getSomeDescription
() { return someDescription;
}
public void setSomeDescription
(String someDescription
) { this.someDescription = someDescription;
}
@Override
return "[" + this.identifier + " - " + this.someDescription + "]";
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNvbWVPYmplY3Qgb2JqMSA9IG5ldyBTb21lT2JqZWN0KDEsICJMb3JlbSBpcHN1bSIpOwoJCVNvbWVPYmplY3Qgb2JqMiA9IChTb21lT2JqZWN0KSBvYmoxLmNsb25lKCk7CgkJCgkJU3lzdGVtLm91dC5wcmludGxuKCJPYmplY3QgMTogIiArIG9iajEpOwoJCVN5c3RlbS5vdXQucHJpbnRsbigiT2JqZWN0IDI6ICIgKyBvYmoy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