1

I know what "this" means, but what does it mean when you put it behind the name of a class, or if you put ".class" behind the name of a class as in the code below?

Someone please explain

Intent intent = new Intent(ActivityA.this, ActivityB.class);

lealceldeiro
  • 14,342
  • 6
  • 49
  • 80
Cedric
  • 470
  • 6
  • 20

2 Answers2

2

ActivityA.this refers to this of the enclosing class (ActivityA).

ActivityB.class simply refers to the ActivityB Class reference.

lealceldeiro
  • 14,342
  • 6
  • 49
  • 80
0

It means this. It's useful for Lambdas, nested classes, etc..

Pshemo
  • 122,468
  • 25
  • 185
  • 269
PeteSabacker
  • 176
  • 8
  • 3
    What makes you say that `this` is useful for lambdas, particularly? – Andy Turner May 17 '19 at 19:24
  • 1
    OP asked: "I know what "this" means, *but what does it mean when you put it behind the name of a class*", to which you answered "It means `this`", but that doesn't look.. enough or even correct. Could you add more details to your answer and explain how `ActivityA.this` is different than only `this`? – Pshemo May 17 '19 at 19:25
  • 1
    Also your answer doesn't address `ActivityB.class`. – Pshemo May 17 '19 at 19:31