标题:java 找不到符号(新手救急!!!)
取消只看楼主
hanxingxing
Rank: 1
等 级:新手上路
帖 子:26
专家分:9
注 册:2010-3-14
结帖率:100%
已结贴  问题点数:20 回复次数:1 
java 找不到符号(新手救急!!!)
本人编了一个判断是否为闰年的小程序,出现了一些问题:
import javax.swing.JOptionPane;
public class year
{
    public static void main(String agrs[])
   {
     String nian;
     String result1;
     String result2;
     int n;
     result1="yes";
     result2="no";
     nian=JOptionPane.showlnputDialog("input the year");
     n=lnteger.parselnt(nian);
     if(n%4==0&&n%100!=0||n%400==0)
        JoptionPane.showMessageDialog(null,"The result is "+result1,"answer",JOptionPane.PLAN_MESSAGE);
     else
        JoptionPane.showMessageDialog(null,"The result is "+result2,"answer",JOptionPane.PLAN_MESSAGE);
   System.exit(0);  
}
}
结果如下:
D:\>javac year.java
year.java:12: 找不到符号
符号: 方法 showlnputDialog(java.lang.String)
位置: 类 javax.swing.JOptionPane
     nian=JOptionPane.showlnputDialog("input the year");
                     ^
year.java:13: 找不到符号
符号: 变量 lnteger
位置: 类 year
     n=lnteger.parselnt(nian);
       ^
year.java:15: 找不到符号
符号: 变量 PLAN_MESSAGE
位置: 类 javax.swing.JOptionPane
        JoptionPane.showMessageDialog(null,"The result is "+result1,"answer",JOp
tionPane.PLAN_MESSAGE);

        ^
year.java:15: 找不到符号
符号: 变量 JoptionPane
位置: 类 year
        JoptionPane.showMessageDialog(null,"The result is "+result1,"answer",JOp
tionPane.PLAN_MESSAGE);
        ^
year.java:17: 找不到符号
符号: 变量 PLAN_MESSAGE
位置: 类 javax.swing.JOptionPane
        JoptionPane.showMessageDialog(null,"The result is "+result2,"answer",JOp
tionPane.PLAN_MESSAGE);

        ^
year.java:17: 找不到符号
符号: 变量 JoptionPane
位置: 类 year
        JoptionPane.showMessageDialog(null,"The result is "+result2,"answer",JOp
tionPane.PLAN_MESSAGE);
        ^
6 错误
搜索更多相关主题的帖子: java 符号 
2010-03-14 17:33
hanxingxing
Rank: 1
等 级:新手上路
帖 子:26
专家分:9
注 册:2010-3-14
得分:0 
回复 4楼 dadongzicool
经过我自己的改正,终于把所有的问题找到了,主要问题是把小写“l”于大写“i”弄混乱了,不过还是谢谢你!!!另外也提醒初学者要看清书本。下面是我改正后的代码(判断是否是闰年):
import javax.swing.JOptionPane;
public class year
{
    public static void main(String agrs[])
   {
     String nian;
     String result1;
     String result2;
     int n;
     int i;
     result1="yes";
     result2="no";
     nian=JOptionPane.showInputDialog("input the year");
     for(i=0;i<nian.length();i++)
     {
      n=nian.charAt(i);
      if(n>='0'&&n<='9') continue;
      else
        {
         JOptionPane.showMessageDialog(null,"Your input is error!!!");
         System.exit(0);
         }
      }
     n=Integer.parseInt(nian);
     if(n%4==0&&n%100!=0||n%400==0)
        JOptionPane.showMessageDialog(null,"The result is "+result1,"answer",JOptionPane.PLAIN_MESSAGE);
     else
        JOptionPane.showMessageDialog(null,"The result is "+result2,"answer",JOptionPane.PLAIN_MESSAGE);
   System.exit(0);  
}
}

我相信每个人都是独立的存在,了解并相信自己才是对自己负责任!
2010-03-16 22:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-299402-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.164659 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved