Wednesday, 18 September 2013

Java Class Saved with another name?

Java Class Saved with another name?

enter code here
class Blog{
public static void main(String args[]){
System.out.println("overflow");
}
}
I am saving this file with name First.java and compiling it than it is
generating file with Blog.class and gives output:-overflow
If same program i am writing as given below:-
public class Blog{
public static void main(String args[]){
System.out.println("overflow");
}
}
it gives error after compiling
First.java:3: error: class Blog is public, should be declared in a file
named Blog.java
public class Java{
^

No comments:

Post a Comment