I recently joined this community as a Java golfer, and I haven't been able to find a definitive consensus on acceptable solution formats for Java.
From what I gather, the following are allowed (please correct if consensus is otherwise):
- full program (class definition with
main
method) - full method (modifiers, signature, body)
- lambda expression
What I'm wondering about is whether a multi-method solution is acceptable.
Description
Such a solution would consist of program text defining two or more methods as they would appear in a class definition, a choice of one such method as an entry point to the program (which would take input and produce output according to standard rules), and, optionally, a class name. To clarify: a multi-method solution would not include fields, initializers, or class definitions; only methods.
Execution
These solutions would be tested by inserting the program text into an empty definition of a public class (as named by the author, if applicable) and then invoking, from a class within the same package, the entry method on an instance of the class produced by the default constructor or on the class itself if the method is static (author's choice).
Rationale
It's easy to imagine this being a desirable format for complex solutions. It permits subroutines more cheaply than a lambda or method solution (where class definitions or functional interface declarations would be required), and it is preferable to a full program solution because I/O can be done flexibly through method parameters and return values and class boilerplate is eliminated.
If this question gets enough activity, I assume consensus will be decided by answer score. Answers may then be affirmative, negative, or affirmative with conditions/exceptions. If this has already been addressed, someone can refer to that discussion and close this one.