• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error: method working in class calculator cannot be applied to given types;

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

I have yet another basic Java problem.

I am practising calling methods. I wrote everything and it compiled okay, but when calling both methods into the main class I came up with the error in the title. (Line 9 in main method).

What noobish thing am I doing wrong? The first calling worked fine but the second gave me an error.

Any help appreciated, and even perhaps what I should do in order not to run into this same problem in the future!

Thanks

Alec

(If I have perhaps not been clear in something please let me know, and sorry for the inconvenience )







[Edit - fixed code tags - MB]
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The working() method in the calculator class takes two integer parameters. Have you passed them?
public void working (int total, int i)
 
Alec Sultana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Jai wrote:The working() method in the calculator class takes two integer parameters. Have you passed them?
public void working (int total, int i)



Umm.. What does pass them mean...?

heh...
 
Greenhorn
Posts: 1
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Jai wrote:The working() method in the calculator class takes two integer parameters. Have you passed them?
public void working (int total, int i)



While calling method, signature of that method must be matched.
Pass two parameters to working method.
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you called the method foo(int i, int j) you told the compiler it must always be passed two numbers. So you need to call it as foo(123, 456) or similar.

And welcome to the Ranch
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For example, you'd call the method like this:
That will get it to compile...but it looks like what you really need to do is somehow get some values from your scan class and pass them to the calculator class.

One more think - you'll find life easier in the long run if you follow established conventions. For Java, that means starting class names with a capital letter - so Method, Calculator and Scan.
 
Alec Sultana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Brown wrote:For example, you'd call the method like this:
That will get it to compile...but it looks like what you really need to do is somehow get some values from your scan class and pass them to the calculator class.

One more think - you'll find life easier in the long run if you follow established conventions. For Java, that means starting class names with a capital letter - so Method, Calculator and Scan.



Thanks for the help, and I will be doing as you said with the conventions:)

Thanks Again
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and Method and Scan are peculiar names for classes. They might be better changed.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic