I can't run a Java program

前端 未结 2 1372
野性不改
野性不改 2021-01-24 07:02

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

相关标签:
2条回答
  • 2021-01-24 07:33

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

    0 讨论(0)
  • 2021-01-24 07:38

    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.

    0 讨论(0)
提交回复
热议问题