Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

"method in class cannot be applied to given types"

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I'm in an intro to java programming course and we're doing a project where we have to use automated testing and create a code and make sure the tests all run successfully, testing each method 1 by 1. The test file is provided for us & cannot be changed. We're using Bluej for this course. Here's part of the test file I'm stuck on:



Here's all of my code:



The getRoaches and breed tests pass, but not the spray test. The error I get in bluej says:

method spray in class RoachPopulation cannot be applied to given types;
required: no arguments
found: int
reason: actual and formal argument lists differ in length

Thanks in advance for any insight you can provide.

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

Your spray() method does not have any input parameters. You need to implement it like

 
Marshal
Posts: 72946
330
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right: an empty method won't do anything It would appear that the spray() method isn't supposed to take any arguments.

And, both of you, welcome to the Ranch
 
Get me the mayor's office! I need to tell him about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic