Arrays.asList(...).contains(...) 如何工作? [英] How Arrays.asList(...).contains(...) works?

查看:112
本文介绍了Arrays.asList(...).contains(...) 如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码..

    String[] weekEnds={"0","6"};

    for(int i=0;i<7;i++){

    if(Arrays.asList(weekEnds).contains(i)){

     System.out.println("I am in the array");       
    }    
  }

但它没有进入 if 条件..我不知道我哪里出错了..提前致谢..

but its not going into the if condition ..i dont know where im going wrong.. Thanks in Advance..

推荐答案

if 条件改为

if(Arrays.asList(weekEnds).contains(String.valueOf(i))){

或者把你的数组改成

Integer[] weekEnds={0,6};

这篇关于Arrays.asList(...).contains(...) 如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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