3

I was starting to learn Java. I followed the tutorial on how to install it. I also checked by typing "javac"(without the quotation marks) in cmd if it works. And yes it gives a whole list of text which means its supposed to work, right?

This is my java code:

class apples{
    public static void main(String args[]) {
        System.out.printIn("hello youtube");
    }
}

I saved it in a folder called 'test' in my c drive. This is what I typed in cmd:

cd \
dir

now it lists everything in my c drive and one of them is test

cd test
dir

Now it lists everything in test and one of them is 'youtube.java'(the file I named), so I type

javac youtube.java

This doesn't work This is what it gives me:

youtube.java:3: error: cannot find symbol
System.out.printIn("hello youtube");
symbol: method printIn(string)
location: variable out of type PrintStream
1 error

Can someone help me out with this?

4

2 回答 2

11

您的通话中有错字。改变

System.out.printIn("hello youtube");  // capital 'I'

System.out.println("hello youtube");  // lowercase 'l'

正如已经提到的,在 Java 中,文件中的public类必须与文件名匹配。

于 2013-07-11T19:12:13.420 回答
0

类的名称必须与文件名匹配。

你应该使用

public class Youtube{

在您的代码中(因为类名大写)并调用文件Youtube.java.

您还使用In了而不是ln.

利用:

System.out.println(

这意味着“将行打印到 System.out”。

于 2013-07-11T19:12:23.833 回答