Answers for "find if the element k is present in the array or not java"

0

how to check if array is full java

int[] candy = new int[10];  //Array size is 10
     //first array: Index 0, last array index: 9. 
     for (int x=0; x < candy.length; x++)
           if (x == candy.length - 1)
                //Reached last element of array
Posted by: Guest on October-19-2020
4

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

Code answers related to "find if the element k is present in the array or not java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language