| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 19087 人关注过本帖
标题:java 找不到符号(新手救急!!!)
只看楼主 加入收藏
hanxingxing
Rank: 1
等 级:新手上路
帖 子:26
专家分:9
注 册:2010-3-14
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:7 
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
【寒冰】
Rank: 2
来 自:北京
等 级:论坛游民
帖 子:9
专家分:39
注 册:2010-3-14
收藏
得分:20 
我们好像学的有点不同,虽然帮补了你,还是帮你顶一下

逆境中生存……
2010-03-14 21:35
dadongzicool
Rank: 6Rank: 6
等 级:贵宾
威 望:11
帖 子:209
专家分:474
注 册:2009-3-20
收藏
得分:0 
D:\>javac year.java
year.java:12: 找不到符号
符号: 方法 showlnputDialog(java.lang.String)//应该是showInputDialog 注意蓝色那个是大写的i不是小写的L
位置: 类 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);//JOptionPane的O要大写  不是PLAN_MESSAGE二十PLAIN_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 错误

本人出售软件专业毕业设计(包括论文,代码)题目众多,价格从优联系方式:QQ
1635008514(寻找高校代理)
2010-03-15 04:10
dadongzicool
Rank: 6Rank: 6
等 级:贵宾
威 望:11
帖 子:209
专家分:474
注 册:2009-3-20
收藏
得分:0 
经测试此程序有很多bug

修改了一下

package cn.dadongzicool.scjp.test4;

import javax.swing.JOptionPane;

public class Year {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         String inputYear;
         String resultYes;
         String resultNo;
         int n = 0;
         resultYes = "Yes";
         resultNo = "No";
         inputYear = JOptionPane.showInputDialog("Input the year");
         try{
             n=Integer.parseInt(inputYear);
             if(n%4==0&&n%100!=0||n%400==0)
                    JOptionPane.showMessageDialog(null,"The result is "
                            +resultYes,"answer",JOptionPane.PLAIN_MESSAGE);
                 else
                    JOptionPane.showMessageDialog(null,"The result is "
                            +resultNo,"answer",JOptionPane.PLAIN_MESSAGE);
                 System.exit(0);
         }
         catch(Exception e){
             JOptionPane.showMessageDialog(null, "wrong", "EventMessage", JOptionPane.PLAIN_MESSAGE);
         }
    }
}

本人出售软件专业毕业设计(包括论文,代码)题目众多,价格从优联系方式:QQ
1635008514(寻找高校代理)
2010-03-15 04:29
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
qq494097058
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-5-13
收藏
得分:0 
我是新手请大家多多帮帮忙!
这是我新建的类:public class Person{
    String name;
    String xingbie;
    int nianling;//属性····
    /*无掺无返回*/
    public void eat(){
    System.out.println("我在吃饭");
}//eat是行为,方法!····
   
}//创建类
这是写好的代码:public class A6_4{
    public static void main(String[] args){
        Person Aa=new Person();
        Aa.name="小明";
        
        System.out.println(Aa.name);

    }
}
出现的错误:找不到符号!
Person Aa=new Person();
^
Person Aa=new Person();
              ^
请各位大神多多帮忙!
2017-05-13 21:26
limoge
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-6-13
收藏
得分:0 
回复 6楼 qq494097058
把person那个类前面的public去掉就好
一个java文件可以有几个类,但是只能有一个public
2017-06-13 14:14
limoge
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-6-13
收藏
得分:0 
回复 6楼 qq494097058
把person那个类前面的public去掉就好
一个java文件可以有几个类,但是只能有一个public
2017-06-13 14:14
快速回复:java 找不到符号(新手救急!!!)
数据加载中...
 
   



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

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