Java Method for removing duplicates from char array

后端 未结 5 1211
礼貌的吻别
礼貌的吻别 2021-01-24 01:40

I have a char array filled by the user (arrayInput[]) with some characters, like {b, d, a, b, f, a, g, a, a, f}, and I need to create a method which returns a new c

5条回答
  •  独厮守ぢ
    2021-01-24 02:19

    Here's the method to achieve what you need:

    public static void main(String[] args) {
        char[] arr= {'A','B','C','A','B'};
    
        HashSet hset=new HashSet();
    
        for(int i=0;i

提交回复
热议问题