Java 中的数组列表 [英] List of Arrays in Java

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

问题描述

在 Java 中创建数组列表的语法是什么?

What is the syntax for making a List of arrays in Java?

我尝试了以下方法:

List<int[]> A = new List<int[]>();

还有很多其他的东西.

我需要能够对 int 数组重新排序,但不需要更改 int 数组的元素.如果这是不可能的,为什么?

I need to be able to reorder the int arrays, but the elements of the int arrays need not to be changed. If this is not possible, why?

谢谢.

推荐答案

首先,你不能做new List();它是一个接口.

Firstly, you can't do new List(); it is an interface.

要制作一个 int 数组列表,请执行以下操作:

To make a list of int Arrays, do something like this :

List<int[]> myList = new ArrayList<int[]>();

PS 根据评论,List 的包是 java.util.List 和 ArrayList 的包是 java.util.ArrayList

P.S. As per the comment, package for List is java.util.List and for ArrayList java.util.ArrayList

这篇关于Java 中的数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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