Cheers,
Prashant.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Prashant,
I'd say: try it out and see what happens!
Greetz,
Piet
Cheers,
Prashant.
There are three kinds of actuaries: those who can count, and those who can't.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:It depends on what you mean by "work". You can certainly compile it that way. You can write classes that don't have any main() method.
but running it is a different issue. if you are going to do this:
>java <MyClassName>
then MyClassName must have a public static void main (String []) method.
Cheers,
Prashant.
There are three kinds of actuaries: those who can count, and those who can't.
Cheers,
Prashant.
java MyClass
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:(ok....you can re-arrange the 'void' and static, and you can name the String array anything, but basically...what I said)
fred rosenberger wrote:So if you only have a "private static void main (String [] args)", the JVM can't find the method it is looking for, and it bails out, not running anything.
fred rosenberger wrote:if you are indeed just beginning, then most folk here would say using the IDE is a bad idea. The IDE hides stuff from you. It politely tries to correct some of your mistakes, but doesn't always tell you. Then things go horribly awry when you run your code, and you are left scratching your head.
You should learn to compile from the command line.
(...)
In that package once you create class then you get syntax like class with {} in file but you do not get
default(ready-made) main() method. You should write it
There are three kinds of actuaries: those who can count, and those who can't.
Prashant Mumbarkar
My question is if instead of public access I write private in front of main() then what will happen?
Rico Felix wrote:
fred rosenberger wrote:(ok....you can re-arrange the 'void' and static, and you can name the String array anything, but basically...what I said)
You cannot re-arrange the void and static keywords, the return type must precede the function identifier directly... what I assumed you meant was that you can re-arrange the access modifier (public) and the non-access modifier (static).
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors