8.1 Java 泛型实现
pln函数 用
class Euphonium{
String nameString;
public Euphonium() {}
public Euphonium(String nameString) {
this.nameString = nameString;
}
@Override
public String toString() {
return "This is Kitauji [Euphonium] ~~~ :"+nameString;
}
}
class Kumiko extends Euphonium{
public String nameString;
public Kumiko(String nameString) {
super(nameString);
this.nameString = "Kousaka Reina";
}
}
public class Mine{
static <T> void pln(T nameString) {
System.out.println(nameString);
}
public static void main(String[] args) {
Kumiko Address = new Kumiko("Oumae");
// System.out.println(Address);
// System.out.println(Address.nameString);
pln(Address);
pln(Address.nameString);
}
}