---
title: "java 反射机制的笔记"
author: "xiaxingwork"
date: "2013-09-26T11:20:20Z"
tags: []
categories: ["移动开发"]
slug: "java"
draft: false
lastmod: "2013-09-26T11:22:01Z"
id: 1947431
url: "https://xiaxingwork.iteye.com/blog/1947431"
---

package com.test.demo

class Demo {

    public interface Listener {

        onCallback();

    }

}

Log.v(TAG, "output : " + Demo.class);   ===&gt;   "output : class com.test.demo.Demo"

Log.v(TAG, "output : " + Listerer.class);  ===&gt;  "output : interface com.test.demo.Demo$Listener "

 

 

```
public static final String WPS_LISTENER = "android.net.wifi.WifiManager$WpsListener";
Method method = WifiManager.class.getMethod("startWps", WpsInfo.class, Class.forName(WPS_LISTENER));
Log.d(TAG, "startWps, method : " + method);
method.invoke(wifiManager, wpsInfo, mWpsListener);
```

 

```
System.out.print(Class.forName("java.lang.String").newInstance().getClass().getName());
```