且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Java中的字符串数组中计算和打印重复的字符串?

更新时间:2023-01-12 21:59:03

先排序数组,然后

for(int i = 0, i < array.length; i++){
    String temp = array[i];
    System.out.print(temp+" ");
    for(int j = i+1; j < array.length; j++){
        String temp2 = array[j];
        if(temp.compareTo(temp2) == 0){
            System.out.print(temp2+" ");
            i++;
        }
    }
    System.out.println();
}

或类似的东西......

or something similar...