public String swapHead(String characterName) {
String originalCharacterName = this.characterName;
this.characterName = characterName;
return originalCharacterName;
}
}
How can I make this code work? What does the error message mean?
public String swapHead(String characterName) {
String originalCharacterName = this.characterName;
this.characterName = characterName;
return originalCharacterName;
}
}
How can I make this code work? What does the error message mean?
It means this.characterName
has a final
modifer, so it can not be re-assigned. You can remove the final
modifier.