Answers for "does the string inside the array contain it in the other array? how to find it java"

5

java check if element exists in array

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");
        }

    }

}
Copy
Posted by: Guest on April-07-2020
2

java check if element exists in array

// Convert to stream and test it
	boolean result = Arrays.stream(alphabet).anyMatch("A"::equals);
	if (result) {
		System.out.println("Hello A");
	}
Copy
Posted by: Guest on April-07-2020
5

java check if element exists in array

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");
        }

    }

}
Copy
Posted by: Guest on April-07-2020
2

java check if element exists in array

// Convert to stream and test it
	boolean result = Arrays.stream(alphabet).anyMatch("A"::equals);
	if (result) {
		System.out.println("Hello A");
	}
Copy
Posted by: Guest on April-07-2020

Code answers related to "does the string inside the array contain it in the other array? how to find it java"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language