I need help with a Java Error

Yoonsi

Beta member
Messages
3
I'm doing this assignment in Java, and its really confusing me. Just wondering if anyone is willing to help. Having said that, I do not want this done FOR me, but help will be nice ^^

What we have to do it program a reverse swedish notation calculator. We have been given a class called DoubleStack.java to complete. Included was a testapplication written by the lecturer that we could run, to see if the individual methods in the class work. However for one particular method, I get a NoSuchMethodError.
Heres a screenshot:
34q46yr.jpg


Any ideas? =(
 
Can you show us
Test1Program at line 33 and 80 (and the lines around it) and Test1App at line 13 (though my guess is thats just creating the instance of Test1Program).

Thanks
 
Oh of course silly me. Here are the screens for line 33, and line 80.

mm92s6.jpg


2md2qgm.jpg


And app at line 13

2qbr8y9.jpg


Thanks! Oh and I apologise for taking so much room.

EDIT: They chose a bad time for the assignment too. Because we've only just finished Classes. This assignment is all about arrays and classes. ugh....
But can you guys see anything wrong with my push method?
 
On line 80. Do

myStack.push(2.0);

The reason your getting a "No Such Method" exception is that in java (and every language) a number without a decimal is considered an integer. That means that
myStack.push(2);
is calling the push() function with an integer when its defined with a double.
 
No actually randomly it just started working...

Thanks for the reply. But when you call a method with an integer when the method has a double for the input, the integer is automatically converted to a double. Not the other way though.
 
Back
Top Bottom