Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Arend van der Kolk
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?

 
Dave Tolls
Rancher
Posts: 2914
36
  • 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
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • 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
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • 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!