In Java, what does a reference to Class.class do?

前端 未结 4 1825
情书的邮戳
情书的邮戳 2021-01-18 19:44

I\'m building a small Android application, but this is more of a Java question than an android question. Looking through the tutorials there are lines that look like:

<
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-18 19:58

    Yes, MyService.class returns a Class object that represents the class MyService. The Intent uses it to identify which Service or Activity you're intending to start.

提交回复
热议问题