Private constructor

xiaoxiao2021-03-19  166

Package Nuaa; Public Class XXX {Public Int A; Private XXX (INT A) {THIS.A = A; System.out.Println ("this.a =" this.a);} / * public static void main String [] args) {xxx duixiang = new xxx (68); int A = 5; system.out.println (duixiang.a a);} * /

}

Package nuaa; public class yanzheng {public static void main (string [] args) {xxx jpu = new xxx (334);}}

The method of the Private Constructor can be instantiated inside the class, and it cannot be instantiated outside the class.

转载请注明原文地址:https://www.9cbs.com/read-130179.html

New Post(0)