Remove duplicates from integer array

前端 未结 23 2375
执念已碎
执念已碎 2020-12-01 18:52

I having a problem with coding this:

Write a static method named removeDuplicates that takes as input an array of integers and returns as a result a new

23条回答
  •  粉色の甜心
    2020-12-01 19:36

    try this.

     int numbers[] = {1,2,3,4,1,2,3,4,5,1,2,3,4};
    
     numbers =  java.util.stream.IntStream.of(numbers).distinct().toArray();
    

提交回复
热议问题