This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Why do these new inner classes "MySendListener" and "MyreadInListener" create errors

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

The BeatBox.java class of HeadFirstJava worked fine untill i added new innerclasses "MySendListener" and "MyreadInListener" (including the buttons with ActionListener) for serializing and saving.

So, the code below works fine without the code about serializeIt and restore. From line 72 to 78 and line 177 to 217
As soon as i add this above code about serializeIt and restore i get errors on line 138 (makeTracks(trackList)), line 139 and 142 track.add(makeEvent()

I cant figure out the negative relation of the new "serializeIt" and "restore" inner classes on these methods named makeTracks(trackList) and track.add(makeEvent().

Any idea?

 
Rancher
Posts: 4174
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error exactly are you getting?
 
Arend van der Kolk
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,

They are compiler errors:

line 138: makeTracks(trackList); // error: The method makeTracks(int []) is undefined for the type BeatBox

line 139: track.add(makeEvent(176,1,127,0,16)); // error: The method makeEvent(int, int, int, int) is undefined for the type BeatBox

line 142: track.add(makeEvent(192,9,1,0,15)); // error: The method makeEvent(int, int, int, int) is undefined for the type BeatBox
 
Bartender
Posts: 708
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your open and close braces - you have mislabeled some of them. The method makeTracks() is placed as a method of myReadIntListener, not BeatBox.
 
Arend van der Kolk
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was indeed the braces. fixed it and works now.

Thank you
 
Marshal
Posts: 65019
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a very common problem. Some IDEs make you write backwards to make sure you pair your braces correctly. Get into the habit of writing backwards yourself when you use a text editor; that will make braces easier to find.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!