我想存储函数输出(保存在txt文件中)以在apriori算法中生成L2。我无法将值复制到任何类型的数据结构。哪里出错了,我想在其他类中重用这个输出。我试图存储在Arraylist,列表等,但是当我打印时,我看到垃圾值。请澄清一下。
print(combination,list1,list2);
public void print(int[] combination, ArrayList<String> list1, ArrayList<String> list2)
{
String[] listArr2 = new String[list2.size()];
list2.toArray(listArr2);
Arrays.sort(listArr2, new Comparator<String>() {
public int compare(String s1, String s2) {
return Integer.valueOf(s1).compareTo(Integer.valueOf(s2));
}
});
ArrayList<String> list5 = new ArrayList<String>();
for(int i = 0 ; i < combLength;i++){
System.out.print(listArr2[combination[i]] + " ");// <---- how to save this return as copy to another class
list5 = Arrays.asList(listArr2[combination[i]] + " ");
}
System.out.println();
System.out.println( list5);
}