What is the extension of Java code files?

97    Asked by BenPHILLIPS in Java , Asked on Jan 15, 2024

 I am currently working on a Java-based project in which I need to create a new Java class. What file extension should I use for this particular Java class file? 

 In the context of Java programming language, the extension for creating a java class is “.java”. During the process, you would need to name the file with the name of the class followed by the “.java extension.

For instance, if you want to create a class whose name is “Myclass” the file should be named “Myclass.java”

Here is the example given

Public class MyClass {
    // Class content goes here
    Public static void main(String[] args) {
        System.out.println(“This is my Java class!”);
    }
}

When you will save the above code to your file, you will get the name of the file in “Myclass.java”. This “.java” extension would prefer that it be the java source code file.



Your Answer

Interviews

Parent Categories