Is Empty .java file name a valid source file name?

Yes, Java allows to save our java file by .java only, we need to compile it by javac .java and run by java classname Let's take a simple example:

class MyClass
{  
    public static void main(String args[])
    {  
        System.out.println("Hello Java!");  
    }  
} 

Here:

  • save above code in file .java only  
  • compile by javac .java  
  • run by java MyClass