创建一个类
是否更高效public class test {
private Circle c;
private String mac;
private Short abstand;
private Location ort;
public test (String mac, Circle c, Short abstand, Location ort){
this.c = c;
this.mac = mac;
this.abstand = abstand;
this.ort = ort;
}
public String erhalteMac()
{
return mac;
}
//etc.
}
使用
创建数组列表ArrayList<test> karte = new ArrayList<test>();
并添加
test t = new test();
t.mac = "...";
karte.add(t);
等
然后查看是否存在具有特定属性的对象
public static boolean hM(ArrayList<object> list, String mac) {
for (object object2 : list) {
if (object2.erhalteMac().equals(mac))
{
//work with object2 here.
return true;
}
}
return false;
}
与简单地为每种类型创建四个数组并在我的情况下仅迭代mac数组并使用每个其他数组中匹配的mac字符串的索引进行更改?