我试图将数组中的每个字符串或int与另一个数组进行比较,然后根据字符串是否存在于另一个数组中来打印结果:下面是整个代码:当尝试使用比较两个值时,我在for循环中得到错误.equals(不确定它是否正确的方法,......我是新来的)请帮忙!
public class comparer {
public void compare (){
ArrayList NameofFileinDir = new ArrayList ();
ArrayList Stocks = new ArrayList();
// populate array with files names in dir
try {
Scanner reads = new Scanner (new File("G:/Programming/StockDataDownload/NameOfFileinDir.txt"));
String FileCode;
while (reads.hasNext()){
FileCode = reads.nextLine(); //read next line
NameofFileinDir.add(FileCode);
}
reads.close();
}
catch (IOException e) {
}
// populate array with original stocks
try {
Scanner reads = new Scanner (new File("G:/Programming/StockDataDownload/AllSecurities.txt"));
String StockCode;
while (reads.hasNext()){
StockCode = reads.nextLine(); //read next …Run Code Online (Sandbox Code Playgroud)