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

[2444 byte] By [Emotionsa] at [2007-11-27 9:42:09]
# 1

public Adder(int x, int y) {

this.x = x;

this.y = y;

}

...

Adder adder = new Adder(userIputForX, userInputForY);

jverda at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 2

public int addNumbers(int z)

{

// put your code here

z=x+y;

System.out.println(z);

return z;

}

Is this method supposed to make sense? Why pass it a value that is ignored?

BigDaddyLoveHandlesa at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 3
Could u tell me a bit more?I still dont understand how do u pass the user's inputs from prompts to the method.
Emotionsa at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 4
Because I am practising about writing a class and then write a driver program to test the class.That's why have to seperate them.
Emotionsa at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 5
I really don't know what you don't understand. http://java.sun.com/docs/books/tutorial/
jverda at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 6
And my lecturer is suck, every lectures she just read the slices and never explains why and how they are.That's why I am so confused.(If ask her, she talks and talks rubbish and eventually I get nothing)
Emotionsa at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 7
Well, I'm sorry, but I can't help you without a better understanding of what your problem is. Maybe somebody else can understand what you're asking.
jverda at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...
# 8
> And my lecturer is suck, every lectures she just read> the slices and never explains why and how they are.> (If ask her, she talks and talks rubbish and> eventually I get nothing)Maybe you should drop the class and complain to the administration.
jverda at 2007-7-12 23:45:04 > top of Java-index,Java Essentials,Java Programming...