Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 大家帮我看以下java代码,这些错误该如何解决?谢谢
cpp





发贴: 3
积分: 0
于 2005-06-24 12:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class FibonacciSerial extends Applet implements ActionListener
{
Label prompt = new Label("请输入菲波那契数列的长度(最大为10): ");
TextField input = new TextField(5);
String[] msg = new String[50];      
int RequireCnt = 0;
int ReturnCnt = 0;

public void init()
{
add(prompt);
add(input);
input.addActionListener(this);
for(int i=0; i<50; i++)
msg[i] = "";
}

public void paint(Graphics g )
{
for(int i = 0; i<RequireCnt + ReturnCnt +1; i++)
g.drawString(msg[i],10, 40+15*i);
}

public void actionPerformed(ActionEvent e)
{
if(e.getSource() ==input)
{
RequireCnt = 0;
ReturnCnt = 0;
if(Integer.parseInt(input.getText()) > 10)
{
prompt.setText("Too Large!");
input.setText("");
}
else
Fibonacci(Integer.parseInt(input.getText()));
}
repaint();
}

long Fibonacci(int n)
{
long temp;

RequireCnt ++;
msg[RequireCnt + ReturnCnt] = Blanks(RequireCnt, ReturnCnt) +
"Fibonacci(" + n + "):" ;
if(n==0||n==1)
{
ReturnCnt ++;
msg[RequireCnt + ReturnCnt] = Blanks(RequireCnt, ReturnCnt-1) +
"Return" + n ;
return n;
}
else
{
temp = Fibonacci(n-1) + Fibonacci(n-2);   //递归计算
ReturnCnt ++;
msg[RequireCnt + ReturnCnt] = Blanks(RequireCnt, ReturnCnt-1) +
"Return" + temp ;
return temp;
}
}

String Blanks(int stepIn, int stepBack)
{
String blank= "";

for(int i=0; i<(stepIn- stepBack); i++)
blank = blank+"";
return blank;
}

}

编译发生错误如下 该如何解决?
FibonacciSerial.java:8: illegal character: \12288
String[] msg = new String[50];      
^
FibonacciSerial.java:8: illegal character: \12288
String[] msg = new String[50];     
^
FibonacciSerial.java:8: illegal character: \12288
String[] msg = new String[50];       ^
FibonacciSerial.java:8: illegal character: \12288
String[] msg = new String[50];       ^
FibonacciSerial.java:8: illegal character: \12288
String[] msg = new String[50];       ^
FibonacciSerial.java:8: illegal character: \12288
String[] msg = new String[50];       ^
FibonacciSerial.java:9: <identifier> expected
int RequireCnt = 0;
^
FibonacciSerial.java:60: illegal character: \12288
temp = Fibonacci(n-1) + Fibonacci(n-2);   
^
FibonacciSerial.java:60: illegal character: \12288
temp = Fibonacci(n-1) + Fibonacci(n-2);   
^
FibonacciSerial.java:60: illegal character: \12288
temp = Fibonacci(n-1) + Fibonacci(n-2);   
^
10 errors


why edited on 2005-06-24 12:16


一个程序员的奋斗历程

话题树型展开
人气 标题 作者 字数 发贴时间
4092 大家帮我看以下java代码,这些错误该如何解决?谢谢 cpp 2682 2005-06-24 12:02
3037 Re:大家帮我看以下java代码,这些错误该如何解决?谢谢 why 199 2005-06-24 12:19

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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