when running this code i am getting an exception how to solve this

501 views java

i am getting this error:

Exception in thread "main" java.lang.NoSuchMethodError: Calc.<init>(II)V
    at ex10thekeywords.main(ex10thekeywords.java:19)
class Calc
    int num1, num2, result;

    public Calc(int number1, int number2) 
        num1 = number1;
        num2 = number2;

public class ex10thekeywords {

    public static void main(String[] args) {

        Calc obj = new Calc(5, 5); // error pointing here as line 19




answered question

Did you compile Calc.java before ex10thekeywords?

1 Answer


Create Calc.java and move the calc class into there, but make sure to make the calc class public.

posted this

Have an answer?


Please login first before posting an answer.