The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

How to call a static method within a static method in the same class?

Hi guys,
I'm trying to call a static method within a static method of the same class, but I can't figure out how. In the tuneAll method below, I'm trying to call tune(Instrument an Instrument). When I try to compile it by just declaring tune(), it says I need an Instrument argument, so then I put Instrument.tune() and it says tune() cannot be found. What am I doing wrong?

Re: How to call a static method within a static method in the same class?

Well tune() takes an Instrument as an argument. So I actually should pass an Instrument argument within the parenthesis, right?. Which means I need to change the Instrument.tune() line to _______.tune(______); but I'm confused as to what.

Re: How to call a static method within a static method in the same class?

It looks to me like you have designed this poorly, it seems to me that tune() should probably NOT be a static method of Instrument, but just a standard method. But in regards to the way you are doing it, you should call it as you were before but pass in the instrument you wish to tune. That is coming from the ArrayList you are looping through.