关于Integer.parseInt()的问题,求高手指点
程序代码:
import java.awt.*; import java.awt.event.*; class YourWindow extends Frame implements ActionListener { TextField text1,text2; PoliceMan police; YourWindow() { text1 = new TextField(10); text2 = new TextField(10); police = new PoliceMan(); setLayout(new FlowLayout()); add(text1); add(text2); text1.addActionListener(this); text1.addActionListener(police); setBounds(100,100,150,150); setVisible(true); validate(); } public void actionPerformed(ActionEvent e) { String number = e.getActionCommand(); int n = Integer.parseInt(number); int m = n*n; text2.setText(n+"的平方是"+m); } } class PoliceMan implements ActionListener { public void actionPerformed (ActionEvent e) { String number = e.getActionCommand(); int n = Integer.parseInt(number); int m =n*n; System.out.println(n+"的立方是"+m); } } public class Example7_4 { public static void main(String args[]) { YourWindow win = new YourWindow(); } }
程序运行时总是提示
在俩个Integer.parseInt处
找不到符号
求高手指点哪地方出错了
谢谢
[ 本帖最后由 tomliu05 于 2011-4-8 14:38 编辑 ]