这是为了实现去除字符串中重复字符的功能
public class MaxStringLength {
public static void main(String[] args) {
String s="abcabcb";
//答案为3
int size = 0;
String req = "(?d)(.)(?=.*\\1)";
s=s.replaceAll(req, "");
for(int i= 0;i < s.length();i++){
size += 1;
System.out.print(s.charAt(i));
}
System.out.println();
System.out.println(size);
}
}
繁星coding