Java Reflection 浅析2
inner class和outer class之间的reflection应用。
package com.gaoqian.reflection;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
class IncludeInnerClass implements Runnable{
class DefaultInnerClass{
int i;
public DefaultInnerClass(){}
DefaultInnerClass(int i){
this.i = i;
}
void innerMethod(){
System.out.println("I am DefaultInnerClass.");
}
}
private class PrivateInnerClass{
int i;
PrivateInnerClass(){}
PrivateInnerClass(int i){
this.i = i;
}
void innerMethod(){
System.out.println("I am PrivateInnerClass.");
}
}
public class PublicInnerClass{
int i;
p
相关文档:
package thread;
class TestThread extends Thread {
public void run(){
while(true){
System.out.println(Thread.currentThread().getName());
}
}
}
public class ThreadDemo {
/**
* @param args
*/
public static void ......
package thread;
class QQ{
private String name;
private String sex;
boolean flag=false;
public synchronized void put(String name,String sex){
if(flag)
try {
wait();
} catch (InterruptedException e ......
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class GB2UTF
{
public static String GBK2Unicode(String str)
{
StringBuffer result = new StringBuffer();
for (int i = 0; i < str.length(); i++)
&n ......