Java int[] array to HashSet

前端 未结 7 2160
感情败类
感情败类 2020-12-29 20:54

I have an array of int:

int[] a = {1, 2, 3};

I need a typed set from it:

Set s;

If I do th

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 21:37

    You can use ArrayUtils in Apache Commons:

    int[] intArray  = { 1, 2, 3 };
    Integer[] integerArray = ArrayUtils.toObject(intArray);
    

提交回复
热议问题