Language syntax

Java this expression

Refers to the current object in a permitted instance context.

Formal Syntax & Structure

java syntaxjava
this.field

Working Example

Example Snippetjava
class Book {    private String title;    Book(String title) { this.title = title; }    String title() { return title; }}public class Main {    public static void main(String[] args) {        Book book = new Book("Atlas");        System.out.println(book.title());    }}
Java Reference