内部类访问外部类的变量必须是final吗? 如下: package com.java.concurrent; class A { int i = 3; public void shout() { class B { public void shout1() { System.out.println(i); } } B b = new B(); b.shout1(); } public static void main(String[] args) { A a = new A(); a.shout…
转载自:https://www.2cto.com/kf/201502/375549.html 非静态方法(不带static)可以访问静态方法(带static),但是反过来就不行,为什么呢? public class test{ public void static main(String args[]){ method(); //会出错,提示你讲method方法改成静态的 method2(); //调用方法正确 new Test2().method(); //正确 } public void m…