开发者

Java - Classes with type?

开发者 https://www.devze.com 2023-03-15 14:07 出处:网络
puclic class ClassA<T> { } what is the following technique called where you can pass a class type to another class and use 开发者_如何学编程it withing the class for type safety? I am talking a
puclic class ClassA<T> {
}

what is the following technique called where you can pass a class type to another class and use 开发者_如何学编程it withing the class for type safety? I am talking about the <T> after my class name


Java generics.

It is the way of typecasting your class so that referential integrity is checked at compile time instead of runtime.

The complete tutorials are at

http://download.oracle.com/javase/tutorial/extra/generics/index.html

http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf


It's called generics. Is that the whole question?

0

精彩评论

暂无评论...
验证码 换一张
取 消