请在 下方输入 要搜索的题目:

说出下列E类中【代码1】~【代码3】的输出结果。class Fish {int weight = 1;}class Lake {Fish fish;void setFish(Fish s){fish = s;}void foodFish(int m) {fish.weight=fish.weight+m;}}public class E {public static void main(String args[]) {FishredFish = new Fish();System.out.println(redFish.weight);//【代码1】Lake lake = new Lake();lake.setFish(redFish);lake.foodFish(120);System.out.println(redFish.weight);//【代码2】System.out.println(lake.fish.weight);//【代码3】}}

说出下列E类中【代码1】~【代码3】的输出结果。class Fish {int weight = 1;}class Lake {Fish fish;void setFish(Fish s){fish = s;}void foodFish(int m) {fish.weight=fish.weight+m;}}public class E {public static void main(String args[]) {FishredFish = new Fish();System.out.println(redFish.weight);//【代码1】Lake lake = new Lake();lake.setFish(redFish);lake.foodFish(120);System.out.println(redFish.weight);//【代码2】System.out.println(lake.fish.weight);//【代码3】}}

发布时间:2024-10-24 10:53:42
推荐参考答案 ( 由 搜搜题库网 官方老师解答 )
联系客服
答案:
专业技术学习
搜搜题找答案
用户信息
没有账号?点我注册
专业技术学习
登录 - 搜搜题库网
立即注册
注册 - 搜搜题库网
验证码
立即登录