I'm trying to add two numbers using multithreading but its showing the following error on compiling :
" constructor Add in class Add cannot be applied to gives types;
class Input extends Add{
required: int,int
found: no arguments
reason: actual and formal arguments lists differ in length
import java.util.Scanner;
class Add implements Runnable{
Thread t;
int a,b,c;
Add(int a,int b){
this.a=a;
this.b=b;
t = new Thread(this,"add");
t.start();
}
public void run(){
c=a+b;
System.out.println("Exiting add thread.");
}
}
class Input extends Add{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
Add o = new Add(5,4);
System.out.println("Enter a string: ");
String str = sc.nextLine();
System.out.println("String is : " + str);
System.out.println("c: " + o.c);
}
}