📄 homebuilder.java
字号:
public class HomeBuilder {
public static void main(String arg[]) {
ThreeBedroomHouse myHouse1 = new ThreeBedroomHouse();
// This is legal.
myHouse1.cleanThirdBedroom();
House myHouse2 = new ThreeBedroomHouse();
// This is not legal. It will generate an error
// at compile time.
myHouse2.cleanThirdBedroom();
// But we could cast myHouse2 to a ThreeBedroomHouse:
ThreeBedroomHouse myHouse3 = (ThreeBedroomHouse) myHouse2;
// So this would be legal:
myHouse3.cleanThirdBedroom();
// Or we could do the casting above in one line
// without using an extra variable
((ThreeBedroomHouse) myHouse2).cleanThirdBedroom();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -