System.out.printLn找不到符号

时间:2011-08-18 10:01:43

标签: java

每当我尝试在命令提示符下编译此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

4 个答案:

答案 0 :(得分:15)

使用l(小写L)打印,而不是I(大写i)。

答案 1 :(得分:2)

错字:

printIn应为println

答案 2 :(得分:1)

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

答案 3 :(得分:1)

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

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

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