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 Employee {
  9. private static Employee emp= new Employee();
  10. private Employee(){
  11.  
  12. }
  13. public static Employee getEmployee(){
  14. return emp;
  15. }
  16. public synchronized void showMsg(){
  17. System.out.println("Hi, I am an employee");
  18. }
  19.  
  20. }
  21.  
  22. class Ideone
  23. {
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. // your code goes here
  27. Employee emp = Employee.getEmployee();
  28. emp.showMsg();
  29. }
  30. }
Success #stdin #stdout 0.09s 54588KB
stdin
Standard input is empty
stdout
Hi, I am an employee