Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-08-2008, 10:12 PM   #1
Beta Member
 
Join Date: May 2008
Posts: 3
Default I need help with a Java Error

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:


Any ideas? =(
__________________

Yoonsi is offline   Reply With Quote
Old 05-08-2008, 10:29 PM   #2
In Runtime
 
Join Date: Apr 2008
Posts: 230
Default Re: I need help with a Java Error

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
__________________

silent1mezzo is offline   Reply With Quote
Old 05-08-2008, 10:57 PM   #3
Beta Member
 
Join Date: May 2008
Posts: 3
Default Re: I need help with a Java Error

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





And app at line 13



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?
Yoonsi is offline   Reply With Quote
Old 05-09-2008, 06:32 AM   #4
In Runtime
 
Join Date: Apr 2008
Posts: 230
Default Re: I need help with a Java Error

On line 80. Do

Quote:
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
Quote:
myStack.push(2);
is calling the push() function with an integer when its defined with a double.
silent1mezzo is offline   Reply With Quote
Old 05-10-2008, 02:51 AM   #5
Beta Member
 
Join Date: May 2008
Posts: 3
Default Re: I need help with a Java Error

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.
Yoonsi is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 09:18 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0