Iam trying to compare each string or int in array with another array then print the results according to whether the string exists or not in the other array: Below is the wh
If you dont want to use for each loop then you can follow this.
for(int i = 0; i < Stocks.size(); i++) {
for (int j = 0; j < NameofFileinDir.size(); j++) {
if (Stocks[i].equals(NameofFileinDir[j])) > 0) {
System.out.println("Stock:" + Stocks[i]);}
else{
System.out.println("Stock not in files:" + Stocks[i]);
}
}
}
In the abovecode, instead of having Stocks[i], have this :
for(int i = 0; i < Stocks.size(); i++) {
for (int j = 0; j < NameofFileinDir.size(); j++) {
if (Stocks.get(i).equals(NameofFileinDir.get(j))) > 0) {
System.out.println("Stock:" + Stocks[i]);}
else{
System.out.println("Stock not in files:" + Stocks.get(i));
}
}
}