Complete a class

Report a typo

Complete the given Singleton class. It should contain the following parts:

  • a private no-argument constructor;
  • a public static method getInstance without arguments, it returns the same instance of the class.

You will not read input or print output in this problem.

If your solution is wrong, you will get a compile-time error or a runtime exception.

Write a program in Java 17
class Singleton {
// write your code here
}
___

Create a free account to access the full topic