如何转换一个int []数组列表? [英] How to convert an int[] array to a List?

查看:111
本文介绍了如何转换一个int []数组列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我预计在code显示真正

  INT []数组= {1,2};
的System.out.println(Arrays.asList(阵列)。载有(1));


解决方案

Arrays.asList(阵列)将导致 INT [] 。

它的工作原理像您期望的,如果你改变 INT [] 整数[] 。不知道有没有什么帮助你,尽管

I expected this code to display true:

int[] array = {1, 2};
System.out.println(Arrays.asList(array).contains(1));

解决方案

The Arrays.asList(array) will result in a singleton list of an int[].

It works as you expect if you change int[] to Integer[]. Don't know if that helps you though.

这篇关于如何转换一个int []数组列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆