/**
* 6-4
* Create two String objects using a String class,
* Find all the same characters for two strings
* and output it on the screen
**/
Import Java.util.arraylist;public class Test{public static void Main (string[] args) {String str1 = "My name is Xingfei Du" ; String str2 = "I like programming."; arraylist<character> array = new arraylist<character> ();/* Find the same all characters */for (int i = 0; i < str1.length (); i++ ) for (int j = 0; J < Str2.length (), j + +) if (Str1.charat (i) = = Str2.charat (j)) Array.add (Str1.charat (i));/* filter out duplicate characters */for (int l = 0; l < array.size (); l++) for (int m = 0; m < array.size (); m++) if (Array.get (L) ==array.get (m)) {Array.remov E (Array.get (m));} for (int i = 0; i < array.size (); i++) System.out.print (Array.get (i) + "");}}
Those years, learned Java 6-4