Compile time error resolution.

How am i suppose to save the ans in a file named after the public class.

Assuming you are referring to Java programs.

Suppose your class is Main, name/renaame your file as Main.java

//