fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. CustomClass dieselEngine= new CustomClass("dieselEngine");
  13. dieselEngine.setProperty1("robust");
  14. dieselEngine.setProperty2("viable");
  15. dieselEngine.setProperty3("affordable");
  16. dieselEngine.showProperties();
  17. }
  18. }
  19.  
  20. class CustomClass {
  21. private String property1;
  22. private String property2;
  23. private String property3;
  24. private String instanceName;
  25.  
  26. public CustomClass(String instance){
  27. this.instanceName =instance;
  28. }
  29. public String getProperty1() {
  30. return property1;
  31. }
  32. public void setProperty1(String property1) {
  33. this.property1 = property1;
  34. }
  35. public String getProperty2() {
  36. return property2;
  37. }
  38. public void setProperty2(String property2) {
  39. this.property2 = property2;
  40. }
  41. public String getProperty3() {
  42. return property3;
  43. }
  44. public void setProperty3(String property3) {
  45. this.property3 = property3;
  46. }
  47. public void showProperties() {
  48. java.lang.System.out
  49. .println("Displaying properties for instance of "+instanceName+" object System:"
  50. + "\nProperty#1: " + property1 + "\nProperty#2: "
  51. + property2 + "\nProperty#3: " + property3);
  52. }
  53. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
Displaying properties for instance of dieselEngine object System:
Property#1: robust
Property#2: viable
Property#3: affordable