正在加载图片...
Processing the roster Array for (int i =0; I< numberofstudents; 1++ Notice how the roster[i]. computeCourseGrade() polymorphism is used here int undergradcount =0; for (int i =0; i< numberofstudents; 1++ Use instance of to f( roster[i] instanceof determine the class UndergraduateStudent ) i the object belongs to undergradcount++i C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 14-7© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 14 - 7 Processing the roster Array for (int i = 0; I < numberOfStudents; i++ ) { roster[i].computeCourseGrade( ); } Use instanceOf to determine the class the object belongs to. int undergradCount = 0; for (int i = 0; i < numberOfStudents; i++ ) { if ( roster[i] instanceOf UndergraduateStudent ) { undergradCount++; } } Notice how the polymorphism is used here
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有