public class study {
private String s = new String("null");
private int petalCount = 0;
study(String ss) {
System.out.println(
"------------------------");
}
study(String s, int petals) {
this(petals);
//! this(s); // Can't call two!
this.s = s; // Another use of "this"
System.out.println("222222222222222222222---"+s);
}
study(int petals) {
petalCount = petals;
System.out.println(
"1111111111111111111111---"
+ petalCount);
}
study() {
this("hi", 47);
System.out.println(
"333333333333333333333333");
}
void print() {
//! this(11); // Not inside non-constructor!
System.out.println(
"petalCount = " + petalCount + " s = "+ s);
}
public static void main(String[] args)
{
study x = new study();
x.print();
}
为什么运行结果是:
1111111111111111111111---47
222222222222222222222---hi
333333333333333333333333
petalCount = 47 s = hi这个构造为什么没有执行:study(String ss)
private String s = new String("null");
private int petalCount = 0;
study(String ss) {
System.out.println(
"------------------------");
}
study(String s, int petals) {
this(petals);
//! this(s); // Can't call two!
this.s = s; // Another use of "this"
System.out.println("222222222222222222222---"+s);
}
study(int petals) {
petalCount = petals;
System.out.println(
"1111111111111111111111---"
+ petalCount);
}
study() {
this("hi", 47);
System.out.println(
"333333333333333333333333");
}
void print() {
//! this(11); // Not inside non-constructor!
System.out.println(
"petalCount = " + petalCount + " s = "+ s);
}
public static void main(String[] args)
{
study x = new study();
x.print();
}
为什么运行结果是:
1111111111111111111111---47
222222222222222222222---hi
333333333333333333333333
petalCount = 47 s = hi这个构造为什么没有执行:study(String ss)
解决方案 »
- 关于s2sh下面开发的webservice下客户端的开发
- 求教各位大哥一个java.sql.SQLException的异常??
- [有关Tomcat如何调试]问一个看似很简单的问题,可能真的很简单
- 一个关于struts tag得问题
- Spring的XML配置文件中的bean的子元素lookup-method的作用是什么
- java中使用了SUN.MISC.BASE64Encoder编码,delphi如何与之产生一样的编码,请教高手
- Message message[] = folder.getMessages();会花很长时间下载邮件么?
- 可乐吧140M 原代码地址,请知道的朋友提供一个?
- 碰到个奇怪的问题了,用JDBC插入一笔记录到数据库,本来是生成一笔记录的,但是实际结果总是多几笔相同的记录,
- JBuilder8+weblogic7整合部署CMP2.0 Bean时出现的问题
- hibernate Hql时间段查询记录
- 关于xfire的webservice
{ study x = new study("输入构造参数,会执行");
x.print();
}
main(String[] args)
调用
study()
调用
study(String s, int petals)
调用
study(int petals)
结束
this(petals);
//! this(s); // Can't call two! 这里被注释掉了this.s = s; // Another use of "this"
System.out.println("222222222222222222222---"+s);
}
main(String[] args)
调用
study()
调用
study(String s, int petals)
调用
study(int petals)
打印1111111111111111111111
回到study(String s, int petals)
打印222222222222222222222
回到study()
打印333333333333
结束