📄 threebedroomhouse.java
字号:
public class ThreeBedroomHouse {
public String streetAddress = "123 Pine Street";
public static final int NUMBEROFBEDROOMS = 3;
public static int getNumberOfBedrooms() {
// This will not work!
// The compiler will produce errors on these two lines
System.out.println("A house with " + NUMBEROFBEDROOMS + " bedrooms at "
+ getStreetAddress());
System.out.println("A house with " + NUMBEROFBEDROOMS + " bedrooms at "
+ streetAddress);
return NUMBEROFBEDROOMS;
}
public String getStreetAddress() {
// These two lines are OK
System.out.println("A house with " + getNumberOfBedrooms()
+ " bedrooms at " + streetAddress);
System.out.println("A house with " + NUMBEROFBEDROOMS + " bedrooms at "
+ streetAddress);
return streetAddress;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -