【发布时间】:2013-04-24 21:11:38
【问题描述】:
我有一个对象 Edges,它有 5 种不同的整数类型与该对象相关联。像这样:
public class Edge implements Comparable {
int weight, tox, toy, fromx, fromy;
public Edge(int x1, int y1, int x2, int y2, int wei) {
tox = x1;
toy = y1;
fromx = x2;
fromy = y2;
weight = wei;
}
public int compareTo(Object obj) {
我想创建一个这些 obj 的数组列表,然后在列表上调用 contains 以查看任意整数是否在任何这些数据类型的列表中,edge.tox edge.toy edge.fromx 或 edge.fromy ....有没有办法做到这一点?
谢谢你
【问题讨论】:
-
等等,你想要
List<Integer>还是List<Edge>?
标签: java arrays list arraylist