I just a wrote a code like this with file name b.java
public class a{
public static void main(String args[]){
System.out.println("Hii");
}
}
it gives error like this
error: class a is public, should be declared in a file named a.java
if i remove access modifier public
in front of class
it is running fine.
is there a other solution to achieve i don't want to change the names of class or file name unless there is a big reason.
If so please explain me the reason. why we should give the name of file and name of the class with same name.