简体   繁体   English

Integer.parseInt错误

[英]Integer.parseInt error

I just began Java. 我刚开始使用Java。 I am trying to compile this program 我正在尝试编译该程序

class poop{
  public static void main(String[] args){
    System.out.println(Integer.parseInt("1"));
  }
}

But I get this error 但是我得到这个错误

poop.java:3: error: cannot find symbol
System.out.println(Integer.parseInt("1"));
                          ^
  symbol:   method parseInt(String)
  location: class Integer
./Integer.java:5: error: cannot find symbol
Int a=5;
^
  symbol:   class Int
  location: class Integer
2 errors

What's up? 这是怎么回事?

I'm using JDK 7 on Lubuntu 我在Lubuntu上使用JDK 7

You have named your java file Integer , but 您已将Java文件命名为Integer ,但是

  1. That doesn't match the class name inside the file ( poop ), and 这与文件( poop )中的类名不匹配,并且
  2. It shadows java.lang.Integer . 它遮盖了java.lang.Integer

Name the file the same thing as the top-level class it contains, and definitely not Integer . 将该文件命名为与其包含的顶级类相同的名称,并且绝对不要使用 Integer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM