Reputation: 21
Given these set of instructons am I right in saying that :
1) Here I declare two list objects called : audiobytes and lines
List<Byte> audioBytes;
List<Line2D.Double> lines;
2) Here I empty the lists created in step 1 , and update the component --> repaint()
public void resetWaveform() {
audioBytes = new ArrayList<Byte>();
lines = new ArrayList<Line2D.Double>();
repaint();
}
3) Here unfortunately I don't understand:
public void createWaveForm() {
// what does it mean ????
if (audioBytes.size() == 0) {
return;
}
}
What puzzles me is that the method is called createWaveForm but actually does nothing..is that correct?
Upvotes: 2
Views: 155
Reputation: 3701
You did not empty the lists in step 2, you threw them away and created 2 new lists. This is not the same if something is still holding a reference to the old lists. You should use the clear()
method instead.
As far as your code in part 3, yes it really does nothing (except needlessly check the size), assuming you haven't cut anything out. If there was something else there, then all that segment of code is saying is "if there is no data, return (don't execute anything more)".
Upvotes: 1
Reputation: 17359
1) Correct
2) Almost. I would create lists in #1 and then call clear()
on each. Simply because dealing with nulls is a nightmare
3) It does nothing only when list of audio bytes has no data. I guess there is more code after the if statement
Upvotes: 1