//to return the current class instance
class demo
{
int a;
int b;
//Default constructor
demo()
{
a = 10;
b = 20;
}
//Method that returns current class instance
// 3
demo get()
{
// 4. returns the instance of class demo
return this;
}
//Displaying value of variables a and b
void display() // 6
{
System.out.println("a = " + a + " b = " + b); // 7
}
}
public class Main
{
public static void main(String[] args)
{
//1. create object of class demo
demo object = new demo();
object.get().display(); // 2 // 5
}
}