我也想知道 不使用API要怎么玩?
public static void main(String[] args) { test("abbcccddddaa"); } public static void test(String str) { int max_length = 0; String max_str = ""; while (str.length() > 0) { int length = str.length(); String first = str.substring(0, 1); str = str.replaceAll(first, ""); if (max_length < length - str.length()) { max_length = length - str.length(); max_str = first; } } System.out.println(max_length); System.out.println(max_str); }
62,614
社区成员
307,327
社区内容
加载中
试试用AI创作助手写篇文章吧