?? ex15(1).java
字號:
// innerclasses/Ex15.java
// TIJ4 Chapter Innerclasses, Exercise 15, page361
/* Create a class with a non-default constructor and no default constructor.
* Create a second class that has a method that returns a reference to an
* object of the first class. Create the object that you return by making an
* anonymous inner class that inherits from the first class.
*/
class One {
private String s;
One(String s) { this.s = s; }
public String showS() { return s; }
}
public class Ex15 {
public One makeOne(String s) {
return new One(s) { };
}
public static void main(String[] args) {
Ex15 x = new Ex15();
System.out.println(x.makeOne("hi").showS());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -