permaculture playing cards*
The moose likes Beginning Java and the fly likes Error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error message" Watch "Error message" New topic
Author

Error message

James Palmer
Ranch Hand

Joined: Mar 15, 2004
Posts: 36
Hello,i have this method in a class:
public int getAnswer(int a) {
a = (number1 + number2);
answer = a;
return answer;
}


I use it in my main method and it gives the error message:
getAnswer(int) in class cannot be applied to ().
Any ideas?Thanks
Darin Niard
Ranch Hand

Joined: Jun 08, 2004
Posts: 118
Do you happen to be calling getAnswer(), without a parameter? Because, that would be your problem.

Your method needs to be passed an int in order for it to work. However, in this case, you shouldn't be using a parameter at all, since all you are doing is assigning something to it. Declare the int inside your method.
 
 
subject: Error message
 
Similar Threads
What' s wrong with this code?
Byte to String problem
polymorphism question
Passing String from struts to javascript
html:radio indexed problem