Har*_*M V 2 java arrays multidimensional-array
我想创建一个多维数组,其中每个节点将具有以下详细信息:
当我有超过30个值时,哪种方法最好?
例:
"班加罗尔","200","城市"
"迈索尔","100","历史性"
我试图在Android中填充一个列表数组,其中每行有三个细节 - 名称,图标,距离,所以我想临时填充我的java类中的数据.
JB *_*zet 21
不要使用多维数组.使用简单的对象数组(或List):
public class Place {
private String name;
private String icon;
private int distance;
// constructor, methods skipped for brevity
}
...
private Place[] places = new Place[10];
// or
private List<Place> places = new ArrayList<Place>();
Run Code Online (Sandbox Code Playgroud)
Java是一种OO语言.学习定义和使用对象.