Life is easy because we write the source code.....
birun
JDBCSupport - An easy to use, light-weight JDBC framework -
If you have an inner class called 'InnerClass' which is defined in OuterClass, there will be two java files : OuterClass.java and OuterClass$InnerClass.java
birun takhellambam wrote:the subclass name which contain main method will be the .java file name.
thanks.
Regards,
Vishnu
Pramod P Deore wrote:There must be only one public class inside one file. and name of file is must be same as name of public class.
Regards,
Vishnu
Life is easy because we write the source code.....
Vishnu Sharma wrote:it will also be containing the main method. Right??
Pushkar Choudhary wrote:
Vishnu Sharma wrote:it will also be containing the main method. Right??
Not always. Every public class need not have a main method.
So in the case, where main method is in different class, which is not public & one public class is also there.
What will be the name of .java file in this case??
Life is easy because we write the source code.....
Pramod P Deore wrote:right
Regards,
Vishnu
Vishnu Sharma wrote:in the case, where main method is in different class, which is not public & one public class is also there.
What will be the name of .java file in this case??
Pramod P Deore wrote:
So in the case, where main method is in different class, which is not public & one public class is also there.
What will be the name of .java file in this case??
name of file must be same as name of public class, but when you run that application then you will het runtime exception as
Exception in thread "main" java.lang.NoSuchMethodError: main
Regards,
Vishnu
Life is easy because we write the source code.....
Rahul J.
Jesper Young wrote:How the source file should be named does not have anything to do with whether the class has a main method or not.
The rule is simple: You can have only one top-level public class per source file. If you put two top-level public classes in the same source file, you will get a compiler error. There is no way around that. The name of the source file must be the same as the name of the single public class that's in the file (with the .java extension, ofcourse).
(By "top-level" I mean a non-nested class).
Regards,
Vishnu
Jesper Young wrote:How the source file should be named does not have anything to do with whether the class has a main method or not.
The rule is simple: You can have only one top-level public class per source file. If you put two top-level public classes in the same source file, you will get a compiler error. There is no way around that. The name of the source file must be the same as the name of the single public class that's in the file (with the .java extension, ofcourse).
(By "top-level" I mean a non-nested class).
Rahul J.
Jesper Young wrote:Rahul, you are mixing up two different things.
2. If your program has a main method, that method must be in a public class, and the method itself must be public static void and take a String[] argument.
Rahul J.
Don't get me started about those stupid light bulbs. |