File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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!