gpt4 book ai didi

android - 如何匹配arraylist中字符串的值

转载 作者:行者123 更新时间:2023-11-29 17:56:35 25 4
gpt4 key购买 nike

如何将字符串与 ArrayList 匹配并检查是否找到或未找到我从 json 获取日期列表并保存在 ArrayList 中。我如何将 ArrayList 与字符串匹配以检查 ArrayList 是否包含字符串值?

字符串采样日期; sampledate="26/5/2013";

    static ArrayList<String> Vacation_Date = new ArrayList<String>();



JSONObject json3 = new JSONObject(str2);

status = json3.getString("status");
if (status.equals("1")) {

JSONArray school = json3.getJSONArray("data");

for (int k = 0; k < school.length(); k++) {
JSONObject jb = (JSONObject) school.getJSONObject(k);
Category_ID.add((long) k);

Vacation_Date.add(jb.getString("date"));
}

if(Vacation_Date.equals(sampledate)
{
//dosomething
}





idid like this
if(Vacation_Date.equals(mydate))

//in debug mode vocation is this [2013-09-29, 2013-09-25, 2013-10-05, 2013-09-27]

// String mydate;
value of mydate in debug mode mydate=///2013-09-19=///2013-09-19

最佳答案

if(!Vacation_Date.contains(jb.getString("date")))
{
Vacation_Date.add(jb.getString("date"));
//Do your stuff here .
}

关于android - 如何匹配arraylist中字符串的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18895921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com