Suppose I have the following class:
public class System {
private String property1;
private String property2;
private String property3;
public void showProperties {
System.out.println("Displaying properties for instance "+<INSTANCE NAME>+"of object System:"
"\nProperty#1: " + property1 +
"\nProperty#2: " + property2 +
"\nProperty#3: " + property3);
}
I'm looking for a way to get the name of the System-instance that will be calling the method showProperties, so that when writing:
System dieselEngine= new System();
mClass.property1 = "robust";
mClass.property2 = "viable";
mClass.property3 = "affordable";
dieselEngine.showProperties();
The console output would be:
Displaying properties for instance dieselEngine of object 'System':
Property#1: robust
Property#2: viable
Property#3: affordable