当前位置: 技术问答>java相关
我是个初学者,一个文件编译通不过,希望高手指点一下
来源: 互联网 发布时间:2015-09-22
本文导语: HelloWorldBean package test; public class HelloWorldBean { private String name; public HelloWorldBean { this.name="world"; } public void setName(String name) { this.name=name; } public String getName() {...
HelloWorldBean
package test;
public class HelloWorldBean
{
private String name;
public HelloWorldBean
{
this.name="world";
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return this.name;
}
}
出错提示
C:TomcatwebappsmywebbeansHelloWorldBean.java:7: expected
public HelloWorldBean
^
C:TomcatwebappsmywebbeansHelloWorldBean.java:20: ';' expected
}
^
2 errors
请问这是为什么呀,各位高手。谢谢了。
package test;
public class HelloWorldBean
{
private String name;
public HelloWorldBean
{
this.name="world";
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return this.name;
}
}
出错提示
C:TomcatwebappsmywebbeansHelloWorldBean.java:7: expected
public HelloWorldBean
^
C:TomcatwebappsmywebbeansHelloWorldBean.java:20: ';' expected
}
^
2 errors
请问这是为什么呀,各位高手。谢谢了。
|
public HelloWorldBean
{
this.name="world";
}
改成:
public HelloWorldBean()
{
this.name="world";
}
{
this.name="world";
}
改成:
public HelloWorldBean()
{
this.name="world";
}
|
agree