-1
    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?

Zappoh
  • 27
  • 1
  • 6
  • It means you declared `characterName` as final. If you want to change it, don't declare it final. – khelwood Jul 01 '18 at 14:29
  • Final variables cannot be reassigned a value. They need to store a value at the time of declaration, and once they are assigned, the stored value cannot be changed. – Dhruv Singhal Jul 01 '18 at 14:36
  • Have you tried this link? https://stackoverflow.com/questions/4012167/java-final-modifier – Dhruv Singhal Jul 01 '18 at 14:41

1 Answers1

0

It means this.characterName has a final modifer, so it can not be re-assigned. You can remove the final modifier.

xingbin
  • 27,410
  • 9
  • 53
  • 103