Sometimes we create the outside world in order to avoid instances of a class, the constructor will be some kind of privatization is about to use its constructor private modifications:
How the outside world to use?
Provide the get method! If the outside world does not provide would not be able to create objects! (Invalid reflection)
Eg:package reviewDemo;
class Stu{
// constructor privatization
private Stu(){
}
}
public class Demo15 {
public static void main(String[] args) {
This s = new this () ;
}
}