麻烦大神们看看
class Fish{ int w = 1; } class Lake { Fish fish; void setFish(Fish s){ //Fish s表示什么意思? fish = s; } void foodFish(int m){ fish.w = fish.w+m; } } public class E { public static void main(String[] args) { // TODO Auto-generated method stub Fish redFish = new Fish(); System.out.println(redFish.w); Lake lake = new Lake(); lake.setFish(redFish); lake.foodFish(120); System.out.println(redFish.w); //请问这个结果怎么得来? System.out.println(lake.fish.w);
输出结果为1 121 121.