Java 中的 ArrayList 是什么意思 [英] what is this mean in the ArrayList in Java

查看:39
本文介绍了Java 中的 ArrayList 是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Java 新手,见过这样的 ArrayList 示例.

 listing = new ArrayList();

我知道如果我想创建一个空数组列表.然后我将使用 ArrayList()

但我不明白ArrayList"和()"之间的是什么.>

谁能给我解释一下?

谢谢

解决方案

这是 Java 泛型. 表示 ArrayList 将只包含 Lot 类型的对象.这很有用,因为编译器可以对您的 ArrayList 进行类型检查.

I'm new in Java, and I have seen a ArrayList example like this.

  listing = new ArrayList<Lot>();

I know that if I want to create an empty array list. Then I will use ArrayList()

But I don't understand what is the <Lot> between the "ArrayList" and "()".

Can someone explain it to me?

Thanks

解决方案

This is Java Generics. The <Lot> indicates that the ArrayList will contain only objects of type Lot. It is useful because the compiler can do type checking on your ArrayList.

这篇关于Java 中的 ArrayList 是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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