how to pass the user's input to the contructor
I have smt like this
Adder.java
publicclass Adder
{
// instance variables - replace the example below with your own
privateint x;
privateint y;
/**
* Constructor for objects of class Adder
*/
public Adder()
{
// initialise instance variables
x = 0;
y = 0;
}
/**
* An example of a method - replace this comment with your own
*
* @param ya sample parameter for a method
* @returnthe sum of x and y
*/
publicint addNumbers(int z)
{
// put your code here
z=x+y;
System.out.println(z);
return z;
}
}
Then I have to write the TestAdder
I did smt like this
TestAdder.java
import javax.swing.*;
publicclass TestAdder
{
publicstaticvoid main(String [] args)
{
for (int i=1;i<=2;i++)
{
String input=JOptionPane.showInputDialog("Enter number "+i);
int num=Integer.parseInt(input);
}
//I dont know how to pass the uer's input the contructor here
Adder myAdd=new Adder();
myAdd.addNumbers();
}
}
Plz explain for me about that

