java类声明< T> [英] java class declaration <T>

查看:149
本文介绍了java类声明< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉简单的类声明 public class test 但我不明白 public class test< T>

I'm familiar with simple class declaration public class test but I don't understand public class test<T>.

推荐答案

< T>指的是泛型类型。
Java中引入了泛型类型,以便为您提供编译时间,并且由于类型擦除(类型安全性),这非常重要。
它在Collections中特别有用,因为它可以让你免于手动转换。

< T > refers to a generic type. Generic types are introduced in Java to provide you with compile time, and this is important due to type erasure, type-safety. It's especially useful in Collections because it frees you from manual casting.

阅读更多关于泛型的知识,特别是关于主题的文档, Angelika Langer非常好: http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html

It is a good idea to read more on generics, especially the documentation on the topic by Angelika Langer is very good: http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html

这篇关于java类声明&lt; T&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆