📄 chapter14n1.java
字号:
/** * demonstration of use of "Moveable" interface */public class Chapter14n1 { public static void main(String[] args) { MyStuff[] collection = new MyStuff[3] ; Moveable[] moveCol = new Moveable[3] ; Student stud = new Student() ; stud.setName("James T. Kirk") ; stud.setLocation(0, 0) ; collection[0] = stud ; moveCol[0] = stud ; Car aCar = new Car() ; aCar.setName("Fiat Uno") ; aCar.setLocation(1, 1) ; collection[1] = aCar ; moveCol[1] = aCar ; Feline aCheetah = new Feline() ; aCheetah.setName("The Flash") ; aCheetah.setLocation(2, 2) ; collection[2] = aCheetah ; moveCol[2] = aCheetah ; // access objects directly System.out.println("Name of aCar is " + aCar.getName() + " Current location is " + aCar.getXLocation() + " " + aCar.getYLocation()) ; System.out.println() ; for (int i = 0 ; i < 3 ; i++) { System.out.println("Name of " + i + "th element is " + collection[i].getName()) ; System.out.println("Current location is " + moveCol[i].getXLocation() + " " + moveCol[i].getYLocation()) ; System.out.println() ; } } // end of method main } // end of class Chapter14n1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -