chapter14n1.java

来自「JAVA源代码程序aashjkjhkjhkjhjkhkj」· Java 代码 · 共 48 行

JAVA
48
字号
/** * 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 + =
减小字号Ctrl + -
显示快捷键?