Files
javaplay/HashMapTest1.java

20 lines
517 B
Java
Raw Permalink Normal View History

2023-03-02 18:06:10 -06:00
import java.util.*;
public class HashMapTest1 {
public static void main(String []args) {
String string1= "ABFED";
String string2= "AFBHI";
HashMap<Character,Boolean> hm1 = new HashMap<>();
for (char theChar : string1.toCharArray()){
hm1.put(theChar ,false);
}
for (char theChar : string2.toCharArray()){
if (hm1.containsKey(theChar)) {
System.out.print(theChar);
}
}
}
}