userimage

how to check in a linkedhashmap have same value

I have a map as below:


Map<String, String> map = new LinkedHashMap<>();
	map.put("C0", "C1");
	map.put("C1", "C2");
	map.put("C2", "C3");
	map.put("V0", "C1");
	map.put("V1", "C2");
	map.put("V2", "C4");

I want the best way to compare/check as below


C0=V0

C1=V1

C2=V2

userimage
Moe
List<String> list = new ArrayList<>(map.values());

for (int i = 0; i < list.size() / 2; i++) {
	if (list.get(i).equals(list.get((list.size() / 2) + i))) {
		System.out.println("duplicate");
	} else {
		System.out.println("not duplicate");
	}
}
Answer is