Reputation: 77
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?
Upvotes: 3
Views: 6762
Reputation: 41281
The name of the class must match the filename.
You should use
public class Youtube{
in your code(as class names are capitalized) and call the file Youtube.java
.
Also you used In
instead of ln
.
Use:
System.out.println(
which means "print line to System.out".
Upvotes: 0
Reputation: 178263
You have a typo in your call. Change
System.out.printIn("hello youtube"); // capital 'I'
to
System.out.println("hello youtube"); // lowercase 'l'
And as has been mentioned already, in Java, the public
class in a file must match the filename.
Upvotes: 11