Skip to content · ⁨Pular para o conteúdo⁩

The this Keyword · ⁨A Palavra-chave this⁩

Handout · ⁨Material de apoio⁩ Watch lesson · ⁨Assistir aula⁩

A parameter can hide the field it should update

  • An object has name "Ada". setName(String name) runs name = name; with the argument "Bo".
  • Both unqualified names refer to the parameter, so the object still has "Ada". this.name = name assigns the parameter value to the field instead.
A parameter can hide the field it should update

Handout · ⁨Material de apoio⁩

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP