这个经典的HelloWorld程序为什么出错呢??(急啊!!)

dingzhanxing 2004-09-08 10:41:37
我照着书写了这个j2me的helloworld 程序
可是有点问题我不知道怎么回事 请高手指点点??


import javax.microdition.midlet.*;
import javax.microdition.lcdui.*;

public class HelloWworld extends MIDlet implements CommandListener
{
private Command exitCommand=null;
private Display display=null;
private TextBox t=null;
public HelloWorld()//问题出在这里??
{
exitCommand=new Command("Exit",Command.EXIT,2);
t=new TextBox("Welcome","Welcome to the j2me magic world!",256,0);
t.addCommand(exitCommand);
t.setCommandListener(this);
}
public void startApp()
{
display=Display.getDisplay(this);
display.getCurrent(t);
}
public void pauseApp()
{
}
public void destroyApp(boolean b)
{
}
public void commandAction(Command cmd,Displayable dis)
{
if(cmd==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
}
}


出现的问题是 public HelloWorld()函数声明需要返回类型 可是我是照着书写进去的树上就没有啊?

请问各位高手是怎么回事 如果需要返回类型 那么是什么类型阿?

多谢了!!!
...全文
256 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangsuipeng 2004-09-13
  • 打赏
  • 举报
回复
JF
harryho 2004-09-12
  • 打赏
  • 举报
回复
构造函数的名字写错了...应与类名相同.
luoye623 2004-09-12
  • 打赏
  • 举报
回复
文件的名字要和类名相一致的,这个错误开始都经常犯的。
没有什么的。
wymm 2004-09-11
  • 打赏
  • 举报
回复
hehe
liuqingyan0425 2004-09-10
  • 打赏
  • 举报
回复
用eclipse 吧
这个好,你那样的问题可以很容易找出来
wumingwangzi 2004-09-10
  • 打赏
  • 举报
回复
哈,有意思
fantasystone 2004-09-10
  • 打赏
  • 举报
回复
两个W啊!!!
gaozhanhai 2004-09-10
  • 打赏
  • 举报
回复
.....这个问题嘛 好说好说... 说实话很难避免的~我也经常这样 运行一下不就知道怎么回事了吗?
prok 2004-09-10
  • 打赏
  • 举报
回复
^_^
王旺旺旺 2004-09-09
  • 打赏
  • 举报
回复
我第一眼就看到你那两个w
feizhou 2004-09-09
  • 打赏
  • 举报
回复
public class HelloWworld extends MIDlet implements CommandListener
~~~~~~~~~~~~
太粗心啦
wandou999 2004-09-09
  • 打赏
  • 举报
回复
HelloWworld
^^^
zuoky 2004-09-09
  • 打赏
  • 举报
回复
哈哈,这个问题我也出现过!
sf5252 2004-09-09
  • 打赏
  • 举报
回复
哈哈,经常出现的问题
以后要细心了
还有了解一般问题出错的时候,你的开发工具提示你错误的是什么类型~~~

要懂得排除这样的小问题,和尽量避免
caiyanying732 2004-09-08
  • 打赏
  • 举报
回复
看看你的类声明:public class HelloWworld extends MIDlet implements CommandListener{
的HelloWorld是不是多了一个"w"
lumber 2004-09-08
  • 打赏
  • 举报
回复
主类的类名写错啦,写成 "HelloWworld "了

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧