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?

7
  • Well, there's no such thing as printIn in Java, so I'd say that error is 100% accurate. Commented Jul 11, 2013 at 19:13
  • 7
    I think downvoting the question is a bit mean, we were all beginners once Commented Jul 11, 2013 at 19:14
  • @NickJ I agree The question contains good content and its clear what the question is. I do not understand the downvotes Commented Jul 11, 2013 at 19:16
  • The real answer is that the OP should be starting with a good beginner's book on Java, or the Oracle tutorials. Commented Jul 11, 2013 at 19:18
  • 2
    SO should introduce a mandatory comment section for downvotes Commented Jul 11, 2013 at 19:34

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Some fonts make such characters appear identical.
@rgettman I wish SO would use this ugly font.
0

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".

1 Comment

Well, you just saved us from a soon to come question. Not completely though. Class name should be public.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.