Ad
  • Custom User Avatar

    This is how I got acquainted with getOrDefault().
    Thanks)

  • Default User Avatar

    It's good coding practice to restrict mutability. As the instance variables are never changed we can make them immutable. Even better: Thus the whole class Dinglemouse becomes immutable - an instance of Dinglemouse can never be changed after initialization. As for the parameters it might not be mandatory to declare them final, but I made it a habit to declare all variables final by default, unless for the rare occasion where I really need a mutable variable. Also it is best avoided to change the value of parameters, so declaring them final makes this more explicit.

  • Custom User Avatar

    Excuse me. why use final in this case?