How do I start my java program?

2

I'm starting in java, and I'm trying to run a program that prints a text. is this:

public class Test {
    public static void main(String[] args) {
        System.out.println("Yass");
    }
}

But I get this:

  

C: Users / myuser / Desktop / myuser / testing.java: 1: error: class Test is public, should be declared in a file called Test.java

But there's the problem: I do not know how to make the Test.java file to run the code

    
asked by Gabriel Mation 02.11.2018 в 01:17
source

1 answer

1

The files that contain Java code must be saved with the same name that you declare in your class, in fact that is what the error tells you.

Entocnes your file should be called

Test.java

Be sure to respect the use of uppercase and lowercase, later the internal code must be the same

public class Test {
    public static void main(String[] args) {
        System.out.println("Yass");
    }
}
  

You should always keep in mind that you are or not working with a IDE   your file .java must have the same name you use for   declare your class

    
answered by 02.11.2018 / 01:21
source