Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStreamReader;
Import Java.util.StringTokenizer;
/**
* Suppose the strings are similar to the ABA and AAB are equal, now give you the two sets of strings, please programmatically compare them to see if they are equal
* */
public class Equaldemo {
public static void Main (string[] args) {
First read to a string of characters
BufferedReader br = new BufferedReader (new InputStreamReader (system.in));
String s = null;
try {
s = Br.readline ();
} catch (IOException e) {
E.printstacktrace ();
}
StringTokenizer st = new StringTokenizer (S, "");
/*if (St.hasmoretokens ()) {
System.out.println (St.nexttoken ());
}*/
String S1=st.nexttoken ();
String s2 = st.nexttoken ();
System.out.println (S1);
SYSTEM.OUT.PRINTLN (S2);
StringBuffer st2 = new StringBuffer (s2);
if (S1.length ()!=s2.length ()) {
System.out.println ("no equals");
Return
}
for (int i = 0;i<s1.length (); i++) {
StringBuffer t = new StringBuffer ();
T.append (S1.charat (i));
int index = 0;
if ((Index=st2.indexof (T.tostring ()))!=-1) {
St2.deletecharat (index);
}else{
System.out.println ("not equals");
Return
}
}
if (St2.length () ==0) {
System.out.println ("equals");
}
}
}
Java Practice Questions: now give two strings, compare them to see if they are equal