?? ex11(3).java
字號:
// typeinfo/Ex11.java
// TIJ4 Chapter Typeinfo, Exercise 11, page 582
// Add Gerbil to the typeinfo.pets library and modify all the examples
// in this chapter to adapt to this new class.
import typeinfo.pets.*;
import net.mindview.util.*;
import static net.mindview.util.Print.*;
/*
// Made following additions:
// typeinfo.pets package:
// typeinfo/pets/Gerbil.java
package typeinfo.pets;
public class Gerbil extends Rodent {
public Gerbil(String name) { super(name); }
public Gerbil() { super(); }
}
// ForNameCreator.java
"typeinfo.pets.Gerbil"
// PetCount.java
if(pet instanceof Gerbil) counter.count("Gerbil");
// LiteralPetCreator.java
Gerbil.class
*/
public class Ex11 {
public static void main(String[] args) {
TypeCounter counter = new TypeCounter(Pet.class);
for(Pet pet : Pets.createArray(20)) {
printnb(pet.getClass().getSimpleName() + " ");
counter.count(pet);
}
print();
print(counter);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -