-1

i have made a file youtube.java in C:\test> but I'm to compile using cmd

I have set the path in environmental variables

C:\Program Files\Java\jdk1.8.0_92\bin

I have code all the coding as given below

class apples{
     public static void main(string args[]){
      system.out.println("hello youtube!");
     }
}

but when I go for compile in cmd error comes as give below

youtube.java:2: error: cannot find symbol
 public static void main(string args[]){
                         ^
  symbol:   class string
  location: class apples
youtube.java:3: error: package system does not exist
  system.out.println("hello youtube!");
        ^
2 errors

PLease help me getting out of this

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

3 Answers3

1

Java is a case sensitive language, and there is not string class...

public static void main(string args[]){

String is the class you need to use..

the same criteria applies for

system.out.println("hello youtube!");

it must be

System.out.println("hello youtube!");
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
0
  1. Please use class name as apples.java when you compile in cmd.

  2. Please use keywords as they are accepted.

    Capitalize the first char s for -

    A. 'String' in line

    public static void main(String args[])

    B. 'System' in line

    System.out.println("Your text here");

0

That is because of error in your method declaration . Correct main method declaration is public static void main(String[]args) . string is not a class in Java . Kindly try to explore things on your behalf before posting a question.

Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39