【发布时间】:2011-04-20 02:07:28
【问题描述】:
我正在使用一个称为矩阵的二维数组。我需要检索数组中的唯一元素。
无 A B C G F
y1 a1 b2 c1 g1 f1
y2 a1 b1 c2 g2 f1
y3 a2 b1 c2 g1 f2
y4 a1 b2 c2 g2 f1
y5 a2 b2 c1 g1 f2
例如,对于 A 列,我应该得到 a1 和 a2。对于 B,b1 和 b2,依此类推。
我尝试了不同的方法,但到目前为止没有任何效果。这是我整理的:
public void UniqueElement(String line){
List tempList = Arrays.asList(line);
Set set = new HashSet(tempList);
System.out.println("");
System.out.printf("%s", set);
}//UniqueElement Method
这是我得到的:
[无,A,B,C,G,F] [y1,a1,b2,c1,g1,f1] [y2,a1,b1,c2,g2,f1] [y3,a2,b1,c2,g1,f2] [y4,a1,b2,c2,g2,f1]
有人可以建议另一种方法来尝试在我的矩阵中挑选出独特的项目吗?
谢谢
【问题讨论】: