This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error message" Watch "Error message" New topic

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.
I agree. Here's the link:
subject: Error message
It's not a secret anymore!