ArrayList<String[]> 中的字符串

Roh*_*nan -7 java string android arraylist

如何检查内部是否存在特定的字符串ArrayList<String[]>

我是否需要迭代每个项目并检查字符串或为此目的的任何特定方法(如ArrayList.contains())?

尝试过 ArrayList.contains() 但在我的情况下不起作用。

这不是一个ArrayList <String>事实ArrayList<String[]>所以这个问题不是一个重复的问题,我问这个是为了好奇是否存在任何特殊方法

Abh*_*hek 5

这是一个示例程序,可以满足您的要求...希望对您有所帮助

public static void main(String[] args) {
        ArrayList<String []> a = new ArrayList<>();
        String b[] = {"not here","not here2"};
        String c[] = {"not here3","i'm here"};
        a.add(b);
        a.add(c);
        for (String[] array : a) {// This loop is used to iterate through the arraylist
            for (String element : array) {//This loop is used to iterate through the array inside the arraylist
                if(element.equalsIgnoreCase("i'm here")){
                    System.out.println("found");
                    return;
                }
            }
        }
        System.out.println("match not found");
}
Run Code Online (Sandbox Code Playgroud)