HashMap<Integer,ArrayList<String>> = new HashMap<Integer,ArrayList<String>>();
ArrayList<constructor> frndList = new ArrayList<constructor> ();
In single hash map i will use the integer value as key and for that key i will be adding multiple values using list
now my question is key 1 having two values that same value is available in key 3 then i have to view that?
You have to manually loop inside your HashMap
dupl = null;
for(ek:map.keys()){
if(ek.get(ek).contains(my_value)){
dupl = ek.get(ek)
break;
}
}
if dupl is not null, you have a value in key ek
System.out.println("Enter first key");
int f=scan.nextInt();
System.out.println("Enter second key");
int s=scan.nextInt();
ArrayList<String> t1=new ArrayList<String>();
ArrayList<String> t2=new ArrayList<String>();
ArrayList<String> mf=new ArrayList<String>();
t1.addAll(map.get(f));
t2.addAll(map.get(s));
for(String temp1:t1)
{
if(t2.contains(temp1))
{
mf.add(temp1);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.