meaning of "return this" meaning of "return this" android android

meaning of "return this"


return this returns the current object instance. I don't know what HotOrNot class is, but it's clear that this method is defined in that class. In the method, member variable ourHelper is initialised with a new database helper and member variable ourDatabase is assigned a writable database object from that helper - after which the instance of the class is returned - most likely, so that the calls could be chained, e.g.

new HotOrNot(myContext).open().runQuery("some query text")

See the Java language specifications for more information on this keyword.