Copy Code code as follows:
Import java.util.ArrayList;
Import java.util.List;
public class Test2 {
/**
* @param args
*/
public static void Main (string[] args) {
String src = "A b c D E b C";
Replace space
src = Src.replaceall ("", "");
System.out.println ("Remove the space after the string:" + src);
list<character> list = new arraylist<character> ();
int[] bb = new int[256];
Char[] cs = Src.tochararray ();
Reverse
int mid = CS.LENGTH/2;
int idx = cs.length-1;
for (int i = 0; i < mid; i++) {
char tmp = cs[i];
Cs[i] = Cs[idx];
CS[IDX] = tmp;
idx--;
}
Statistics, and filters the same
for (char C:cs) {
if (Bb[c] <1) {
List.add (c);
}
BB[C] = Bb[c] + 1;
}
System.out.println ();
for (int i = 0; i < list.size (); i++) {
System.out.print (List.get (i));
}
System.out.println ();
for (int i = 0; i < list.size (); i++) {
char C = list.get (i);
System.out.println (c + "" + bb[c] + "Times");
}
}
}
String a = "ABCD,EFG";
String B = ") (*&^%$#@![] {},.//;:'? <> ";
To be to determine if any character in string a appears in string B, the higher the efficiency the better
* Find out if certain characters appear in another string
Copy Code code as follows:
*
* @author java person (java2000.net)
*/
public class Test {
/**
* @param args
*/
public static void Main (string[] args) {
String a = "ABCD,EFG";
String B = ") (*&^%$#@![] {},.///;:'? <> ";
byte[] bb = new byte[256];
Char[] cs = B.tochararray ();
for (char C:cs) {
BB[C] = 1;
}
cs = A.tochararray ();
for (char C:cs) {
if (bb[c] = = 1) {
System.out.println (c);
}
}
}
}