i am writing the code for method overloading to study polymorphism. Vs code is showing no red line while writing the code but in the output all the previous errors of previous files are shown and after proceeding for java debugger to terminal "Exception in thread "main" java.lang.Error: Unresolved compilation problem:" this is output. How can I resolve this ?
public class Oops_Polymorphism_MethodOverloading {
public static void main(String args[]) {
Calculator calc = new Calculator();
System.out.println(calc.sum(1, 2));
System.out.println(calc.sum(1, 2, 3));
System.out.println(calc.sum((float)1.5 , (float)2.5));
}
} class Calculator {
int sum (int a, int b) {
return a + b;
}
int sum (int a, int b, int c) {
return a + b + c;
}
float sum (float a , float b) {
return a + b;
}
}