JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Random;
public class Main {
public static void main(String[] a) {
Singleton.INSTANCE.awesomeMethod();
}
}
public class Singleton {
public static Singleton INSTANCE = new Singleton();
private Singleton() {} //not accessible outside
public void awesomeMethod() {
//x = random integer from 0 to 99
Random random = new Random();
System.out.println(random.nextInt(100));
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run