怎么获取一个类中的匿名内部类的数据然后在本类使用,

解决方案 »

  1.   

    private String str1 = null; //类级别的变量    public void test() {        final String[] str2 = new String[1]; //方法级别的变量        new Thread(new Runnable() {
                @Override
                public void run() {
                    str1 = "hello str1";
                    str2[0] = "hello str2";
                }
            }).start();        try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }        System.out.println(str1);
            System.out.println(str2[0]);
        }