Help: Can't get my string to work
in
Programming Questions
•
1 year ago
My playOtherReflection and playMyReflection commands keep returning an error message:
void playOtherReflection(){
playOtherSong(findReflection(LastReflection.getComboName(),false));
}
void playMyReflection(){
playOtherSong(findReflection(LastReflection.getComboName(), true));
}
String findReflection(int targetCombo){
ArrayList reflectionSubset = new ArrayList();
Random randomGenerator = new Random();
Iterator iterator = reflectionList.iterator();
reflectionEntry selectedReflection;
while(iterator.hasNext()){
selectedReflection = (reflectionEntry) iterator.next();
if(selectedReflection.getComboName()==targetCombo){
reflectionSubset.add(selectedReflection);
}
// else{ // looking for someone else's reflections
//if(selectedReflection.getComboName()!=targetCombo){
// reflectionSubset.add(selectedReflection);
//}
}
// if nothing in subset array, return nothing
if(reflectionSubset.size()==0) return(null);
int index = randomGenerator.nextInt(reflectionSubset.size());
return(((reflectionEntry)reflectionSubset.get(index)).getFileName());
}
1