import java.util.hashmap;import java.util.hashset;import java.util.iterator;import Java.util.map;import java.util.set;public class test { public static void main (String[] args) { String s1 = "123456ABCDE"; string s2 = "111222BBBCC"; system.out.println (New test (). Findsame (S1,&NBSP;S2)); } public string findsame (STRING&NBSP;S1,&NBSP;STRING&NBSP;S2) { Map Map = new hashmap (); set result = new hashset (); char [] char1 = s1.tochararray (); char[] char2 = s2.tochararray (); for (int i = 0; i < char1.length; i++) { map.put (" + char1[i], char1[i]); } for (int j = 0; j < char2. length; j++) { if (Map.get (" + char2[j]) != null) { result.add (Char2[j]); } } /*for ( Iterator it = result.iterator (); it.hasnext (); ) { system.out.println ("value=" +it.next (). toString ()); }*/ return result.tostring (); }}
Find the same characters in two strings and go back to the