1

I usually see in other codes which use final key word to inject Service Bean to Controllers, some code are not. So, what's the reason to use "final" in this. I know final variable that means it's immutable variable. I research some blogs that they say it relates to thread-safe.

user7294900
  • 52,490
  • 20
  • 92
  • 189

1 Answers1

3

Use final when using constructor injection:

constructor injection lets the riskAssessor field be marked as final, indicating that it cannot be subsequently changed

user7294900
  • 52,490
  • 20
  • 92
  • 189