# When do I have to include things like Java's public static void main

Can someone tell me why sometimes people are including class C{public static void main(String[]a){...}} and sometimes that seems to be not necessary?(https://codegolf.stackexchange.com/a/62373/46569)

Whenever submissions are required to be full programs, Java's standard boilerplate code (i.e. class and main, etc.) is required. When submissions are allowed to be functions, this boilerplate is not required.

• Unless the OP specifies otherwise, I think @AlexA. means. – Addison Crump Nov 18 '15 at 19:56
• @VoteToClose I can't imagine a situation where the OP would require boilerplate for a function (thereby making it a full program) or not require boilerplate for a full program (thereby making it a snippet, which aren't allowed by default). – Alex A. Nov 18 '15 at 20:01
• You could have a fickle OP :P – Conor O'Brien Nov 18 '15 at 20:01
• I meant "Unless the OP specifies otherwise, submissions are required to be full programs..." c: – Addison Crump Nov 18 '15 at 20:10
• When it's a function, that doesn't mean just a function body though. So you still need the function header and whatnot, even though you don't need the rest of the boilerplate. – SuperJedi224 Nov 18 '15 at 20:16
• Thanks for your answers, I actually completely missed the "write a program or function" – Joba Nov 18 '15 at 21:02
• @VoteToClose Except that the default is the other way around. If not specified, functions are fine: meta.codegolf.stackexchange.com/q/2419/14215 – Geobits Nov 19 '15 at 14:08