threebedroomhouse.java
来自「orcale9i-java-programming外文书籍源码,结合orcale」· Java 代码 · 共 28 行
JAVA
28 行
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 + =
减小字号Ctrl + -
显示快捷键?