【问题标题】:System.out.printIn cannot find symbol [duplicate]System.out.printLn 找不到符号 [重复]
【发布时间】:2011-10-29 15:45:51
【问题描述】:

每当我尝试在命令提示符下编译这个 Java 程序时,我都会收到一个关于 System.out.printIn 的错误,说 javac 找不到符号。 System.out.print 工作得很好,但 System.out.printIn 拒绝合作。我已经在下面发布了程序和编译器消息。感谢您的帮助。

    public class BeerSong {
public static void main (String[] args) {
int beerNum = 99;
String word = "bottles";

while (beerNum > 0) {

  if (beerNum == 1) {
    word = "bottle"; //singular, ONE bottle
}

System.out.printIn(beerNum + " " + word + "of beer on the wall");
System.out.printIn(beerNum + " " + word + "of beer.");
System.out.printIn("Take one down.");
System.out.printIn("Pass it around.");
beerNum = beerNum - 1;

if (beerNum > 0) {
    System.out.printIn(beerNum + " " + word + " of beer on the wall");
}   else {
    System.out.printIn("No more bottles of beer on the wall");
} //end else
} //end while loop
} //end main method
} //end class

C:\Users\Jesse\Desktop>javac BeerSong.java
BeerSong.java:12: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn(beerNum + " " + word + "of beer on the wall");
              ^
BeerSong.java:13: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn(beerNum + " " + word + "of beer.");
              ^
BeerSong.java:14: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn("Take one down.");
              ^
BeerSong.java:15: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn("Pass it around.");
              ^
BeerSong.java:19: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
        System.out.printIn(beerNum + " " + word + " of beer on the wall");
                  ^
BeerSong.java:21: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
            System.out.printIn("No more bottles of beer on the wall");
                      ^
6 errors

【问题讨论】:

  • 什么是printIn 应该是println
  • 真正的答案是啤酒和 Java 不能同时使用 :-)

标签: java


【解决方案1】:

它是带有l(小写L)的println,而不是I(大写i)。

【讨论】:

  • 另外:ln 代表line 在打印行中,而不是 printIn => print ...输入?! ;)
  • 我觉得这很简单。非常感谢。这就是我使用模糊的 pdf Java 指南所得到的。
  • 哇,这太愚蠢了。camelCase怎么了?
  • 我也相信大写I!谢谢!
【解决方案2】:

错字:

printIn 应该是println

【讨论】:

    【解决方案3】:

    应该是System.out.println 而不是System.out.printIn

    使用某种 IDE(如 Eclipse 或 NetBeans)来确保您可以在当前上下文中使用方法。

    这里的问题是复制同一行。尽量避免复制/粘贴。

    【讨论】:

      【解决方案4】:

      它是 System.out.println 而不是 System.out.printIn(小写 L 而不是大写 i)

      【讨论】:

      • 在他的帖子中是字母 I 和上 i :)
      猜你喜欢
      • 2010-10-12
      • 2019-05-31
      • 2015-06-07
      • 2020-06-13
      • 2012-09-09
      • 2015-12-15
      • 1970-01-01
      相关资源
      最近更新 更多