SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Jesper Young wrote:Are you sure that your code compiles? It shouldn't, because you are creating a new Math object with: Math m = new Math(); but your class Math does not have a constructor that takes no arguments.
Jesper Young wrote:No, you aren't. Look in the source code that you posted above. You have this line in the main() method:
Math m = new Math();
If you try to compile that, you will get a compiler error, because your class Math does not have a constructor that takes no arguments. It only has a constructor that takes two int arguments:
I don't see two arguments 7 and 4 being passed in your code above.
Maybe your actual code is different from what you posted above. Are you really doing this?
Math m = new Math(7, 4);
If yes, then why are you surprised at the output? Because 7 + 4 = 11 and 7 - 4 = 3.
charushila ingale wrote:my code is different from this
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
charushila ingale wrote:you are true and i want addition of those number which are given by user mean i want addition of number 2 and 3
You can do anything, but not everything