동기의 이것저것
article thumbnail
728x90

int 배열을 List로 바꿔서 contains 를 사용하려고 하였으나 안되었다. 이유가 뭘까?

 

혹시나 해서 Integer로 해보았다.

 

Integer은 된다?

 

아.. 

List <int [] > 이런 형태로 반환하니까 안되는구나...

 

https://stackoverflow.com/questions/1467913/arrays-aslist-not-working-as-it-should

 

Arrays.asList() not working as it should?

I have a float[] and i would like to get a list with the same elements. I could do the ugly thing of adding them one by one but i wanted to use the Arrays.asList method. There is a problem though. ...

stackoverflow.com

stackoverflow에도 있네요!

 

그렇다면 List의 contains 와 같이 쓰고 싶다면 어떤 방법이 있을까?

 

여기서 확인해보자!

 

https://dongki1882.tistory.com/49

 

[Java] int 배열 인덱스 찾기 Arrays.binaraySearch() ( list의 contains 처럼 )

여러가지 방법이 있겠지만 오늘 해볼 방법은 int[] arr = {1,2,3}; int index = Arrays.binarySearch(arr, 3); Arrays.binarySearch() 를 사용해볼것이다. 이 메서드는 들어가서 확인해보니 이렇게 되어 있다. 즉 키를 찾

dongki1882.tistory.com

 

728x90
반응형
profile

동기의 이것저것

@U_motivation

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!