fork download
  1. public class Test {
  2. int a = 1;
  3. int b = 2;
  4.  
  5. int calcSum(int a, int b) {
  6. return (a + b);
  7. }
  8.  
  9. public static void main(String[] args) {
  10. Test t = new Test();
  11. int c = t.calcSum(a, b);
  12. System.out.println(c);
  13. }
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: class Test is public, should be declared in a file named Test.java
public class Test {
       ^
Main.java:11: non-static variable a cannot be referenced from a static context
    int c = t.calcSum(a, b);
                      ^
Main.java:11: non-static variable b cannot be referenced from a static context
    int c = t.calcSum(a, b);
                         ^
3 errors
stdout
Standard output is empty