• 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

signal generator part 2

 
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Continued from this page (https://coderanch.com/t/656287/GUI/java/signal-generator)
I have cleaned up my code and now trying to call another class, which the program will do, but I get this error:

SIGGEN_msc.java:58: error: method generate in class oscillate cannot be applied to given types;
if (a.equals("Sine")) { o.generate(fre,len,amp,"Sine"); textArea.setText("Sine\n"); }
^
required: int,int,int
found: int,int,int,String
reason: actual and formal argument lists differ in length


This error continues on lines 59, 60, 61, and 62.
From what I gather, it is telling me that it is not finding the String type, but String is called as an ActionPerformed event.
I will include my code, and a snippet of the oscillate code.





Thank you.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephen Carter wrote:I get this error:

SIGGEN_msc.java:58: error: method generate in class oscillate cannot be applied to given types;
if (a.equals("Sine")) { o.generate(fre,len,amp,"Sine"); textArea.setText("Sine\n"); }
^
required: int,int,int
found: int,int,int,String
reason: actual and formal argument lists differ in length


From what I gather, it is telling me that it is not finding the String type, but String is called as an ActionPerformed event.



Nope. It is telling you that it can't find a generate() method of the occillate class that takes four parameters -- specifically an int, int, int, and String. The closest match that it could find is the method that takes three ints.

Henry
 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only code that is relevant here is all of the code for the oscillate class (Note: By convention, class names should always begin with a capital letter). The error message is quite explicit - you haven't defined a method called "generate" that takes four arguments (int,int,int,String) but you are trying to call such a method.
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I have to include string in the oscillate class? (the snippet I provided).
 
Fred Kleinschmidt
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you have to define a function called "generate" IN THE OSCILLATE CLASS, THAT TQAKES FOUR ARGUMENTS:
`public void generate (int firstInt, int secondInt, int thirdInt, String someString ) {
// do something here using the above arguments
}`
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Fred Kleinschmidt wrote:No, you have to define a function called "generate" IN THE OSCILLATE CLASS, THAT TQAKES FOUR ARGUMENTS:
`public void generate (int firstInt, int secondInt, int thirdInt, String someString ) {
// do something here using the above arguments
}`



Thank you for your reply. I added that to oscillate class and when I try to compile siggen i get


SIGGEN_msc.java:58: error: unreported exception LineUnavailableException; must be caught or declared to be thrown
if (w.equals("Sine")) { o.generate(fre,len,amp,"Sine"); textArea.setText("Sine\n"); }



Nothing has been changed in siggen.java
^



EDIT

Fixed it and it works. Thank you all.
 
Fred Kleinschmidt
Bartender
Posts: 732
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This method is infinite recursion - calling it will create a stack overflow exception.
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Fred Kleinschmidt wrote:

This method is infinite recursion - calling it will create a stack overflow exception.



It hasn't yet.

I am going to close this thread. Thank you for your replies.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic