Originally posted by Girish Nagaraj:
Why is it necessary to give file name same as the class name which has main method.
I disagree to above statement
As per my understanding file name shall be same as public class declared in file.if you donot have any public class in a file.YOu can give any name to your .java file.
YOu can save example below with any name,I saved it as MyTest.java
compile it using javac MyTest.java
and run it with java TestMain
}