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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -