Topic: 主类里面的构造函数在MAIN里不能调用!

  Print this page

1.主类里面的构造函数在MAIN里不能调用! Copy to clipboard
Posted by: umbrella
Posted on: 2004-03-10 10:02

public class mymail {

public mymail()
{
int j=10;
for(int i=0;i<j;i++)
{
System.out.printLight Bulb;
}

}

public static void main(String[] args) {
mymail(); //这里说找不到该方法?何解?
}

}

2.Re:主类里面的构造函数在MAIN里不能调用! [Re: umbrella] Copy to clipboard
Posted by: mochow
Posted on: 2004-03-10 10:26

建议找一本最基本的书看看,看看hello world是怎么运行成功的

3.Re:主类里面的构造函数在MAIN里不能调用! [Re: umbrella] Copy to clipboard
Posted by: snakeqi
Posted on: 2004-03-10 11:32

在main里调用跟外部调用一样,先要生成对象才能使用

public void main(String[] args){
mymail mail = new mymail();//这里就自动调用构造函数了
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923