[20-05-18][Thinking in Java 25]Java Inner Class 9 - Anonymous Inner Class 4
2021-01-18 10:12
标签:ati thinking return sys span stat 结果 think ret 结果如下: this is 10 [20-05-18][Thinking in Java 25]Java Inner Class 9 - Anonymous Inner Class 4 标签:ati thinking return sys span stat 结果 think ret 原文地址:https://www.cnblogs.com/mirai3usi9/p/12913841.html 1 package test_16_2;
2
3 public class Outter {
4
5 public Outter() {
6
7 }
8
9 public Outter(int i) {
10
11 this.i = i;
12 }
13
14 private int i = 1;
15
16 private void show() {
17 System.out.println("this is " + i);
18 }
19
20 public Outter outter(int x) {
21
22 return new Outter(x) {
23
24 {
25 i = x;
26 show();
27 }
28 };
29 }
30
31 public int getI() {
32
33 return i;
34 }
35
36 public static void main(String[] args) {
37
38 Outter outter = new Outter();
39 outter.outter(10);
40 System.out.println(outter.getI());
41 }
42 }
10
上一篇:python学习第十四天
文章标题:[20-05-18][Thinking in Java 25]Java Inner Class 9 - Anonymous Inner Class 4
文章链接:http://soscw.com/index.php/essay/43616.html