I want to compare 2 array of different dimension and then eliminate the duplicate and put the result on array called tmp
Here is the code
ArrayList<String> list = new ArrayList<String>();
HashSet<String> tmp = new HashSet<String>();
try
{
String query1="SELECT ID FROM Apps;";
ResultSet rs = con.createStatement().executeQuery(query1);
while(rs.next())
{
list.add(rs.getString("ID"));
tmp.add(rs.getString("ID"));
}
for(int i=0;i < check.size();i++)//ciclo le checkbox selezionate
{
check.get(i);
String query="UPDATE Apps SET Authorized='1' WHERE ID=" +check.get(i);//vado ad eseguire la query di update
pr=con.prepareStatement(query);
pr.executeUpdate();
tmp.add(check.get(i).toString());
}
System.out.println(tmp);
The content of the two arrays is:
check -> [1, 2]
list -> [1, 2, 3, 4, 5]
The result I want is tmp -> [3,4,5]
but the console show tmp -> [1,2,3,4,5]