42 Where we can use "this" keyword in our Java file?

Code:

class Demo
{
static
{
}
{
System.out.println("nsb: " + this.hashCode() );
  }

Demo()
{
System.out.println("cons: " + this.hashCode() );
}

void m1()
{
System.out.println("m1(): " + this.hashCode() );
}

public static void main( String args[] )
{
Demo d = new Demo();
d.m1();
}
}


Output:  


We can use this keyword in Non static Block , Non Static method and in Constructor
Previous
Next Post »