视频里讲过, 很简单, 看下代码就能明白了.- public class Test {
-
- public Test()
- {
- System.out.println("Test()");
- }
-
- public Test(int x)
- {
- this(); //this语句要写在构造器的第一行.
- System.out.println("Test() " + x);
- }
-
- public static void main(String[] args) {
-
- new Test();
- System.out.println("===============");
- new Test(4);
- }
-
- }
复制代码 |