What does the this keyword refer to in Java, and where is it actually useful?
this is a reference to the current object — the instance whose method or constructor is executing. It is an implicit parameter that every non-static method and constructor has, and it exists so you can refer to the current object explicitly.
There are four places you will actually use it. In a constructor, this.field = field distinguishes the field from a parameter of the same name. In a method, this.method() calls another method on the same object, which matters when a parameter shadows a method name. As this(...) in a constructor, it delegates to another constructor of the same class. And as a bare expression, return this; returns the current object, which is how a builder method or a fluent API returns itself for chaining.
Two restrictions are worth stating precisely. this cannot be used in a static method or in a static initializer block, because there is no current object in a static context — the compiler rejects it with the message that a non-static variable cannot be referenced from a static context. And in a constructor, this(...) must be the first statement, for the same reason super(...) must be: the object has to be fully set up before you delegate.
One thing this cannot do is change the static type of a reference. this always has the type of the current object at compile time, which is why you cannot assign it to a variable of a supertype and expect the compiler to forget the subclass methods.