Answers for "java 7 if java string array contains"

1

java if one sting on array match

String[] fieldsToInclude = { "id", "name", "location" };

if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) {
    // Do some stuff.
}
Posted by: Guest on February-13-2021
-2

array contains java

StringArrayExample1.java

package com.mkyong.core;

import java.util.Arrays;
import java.util.List;

public class StringArrayExample1 {

    public static void main(String[] args) {

        String[] alphabet = new String[]{"A", "B", "C"};

        // Convert String Array to List
        List<String> list = Arrays.asList(alphabet);
        
        if(list.contains("A")){
            System.out.println("Hello A");
        }

    }

}
Posted by: Guest on February-13-2021

Code answers related to "java 7 if java string array contains"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language