Apologies for the confusion
a) the file should be named test.java, as pointed out earlier
b) I am using Jcreator as an
IDE. If I use the compile file and execute file options, the program executes. If I use cmd line on Windows
java test (with test in java sdk's bin)
I get an exception
Exception in
thread "main" java.lang.NoSuchMethodError: main
any suggestions. I used to think Jcreator will call the usual cmd line. However, this does not appear to be the case. Am I missing anything?
c) This is for Valentin Crettaz
Thanks for your tests.
The problem that I keep on having with main is that I just know one single rule
that if there is a method named main,
it should have a signature of public static void main (Strings args[]))
There was an implicit assumption that main will be mentioned only once in a public top level class
That assumption proved to be untrue.
There may be other issues eg. if a child and parent class both have main (with child as public)
can the child's main invoke the parent's main
(or vice versa).
Similarly, can main be a part of an interface?
is it ok if a public top level class also implements that interface?
Of course, I can try this out by compiling.However, I guess there would be a rule (or a couple of them) out there that will cover all the possible cases and prevent any surprises.
Thanks for the help and for having hte patience to read until this point :-)