Submitting in Java in SPOJ -
i tried submitting program many classes in java , spoj did not accept showing compilation errors . how submit multi class programs in java in spoj
you can submit multi class java programs spoj.
just define them inner classes of main class.
note inner class(es) not need static.
find below sscce (short, self contained, correct, example):
public class main { static class 1 { static int getvalue() { return 1; } } static class 2 { static int getvalue() { return 2; } } static class calculator { static void printresult() { int sum = one.getvalue() + two.getvalue(); system.out.println("the sum " + sum + "."); } } public static void main(string[] args) { calculator.printresult(); } }
output: sum 3.
Comments
Post a Comment