在java的一个类中,可能含有多个构造函数,如果其中的构造函数调用其他的构造函数,不能直接写构造函数名,应该用关键字this调用.
例如:
01.public class Test{
02. public Test(){
03. this(1);
04. }
05. public Test(int i){
06. System.out.println(i);
07. }
08.}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|