Menu
Question Index
...

Write a program to find the given value is equals to any of the list of values.

Input (String inputValue, Array of strings) Output
Virat Kohli
{Sachin Tendulkar, Dhoni, Sehwag, Yuvraj Singh, Virat Kohli, Gautam Gambhir, Suresh Raina, Rohit Sharma}
true
Mango
{Apple, Orange, Banana, Pineapple, Mango, Sapodilla, Watermelon, Custard Apple}
true
CSE
{ECE, IT, CSE, MEC, EEE, CIVIL}
true
MCA
{ECE, IT, CSE, MEC, EEE, CIVIL}
false
Ashwin
{Sachin Tendulkar, Dhoni, Sehwag, Yuvraj Singh, Virat Kohli, Gautam Gambhir, Suresh Raina, Rohit Sharma}
false
"" {EMPTY STRING}
{Sachin Tendulkar, Dhoni, Sehwag, Yuvraj Singh, Virat Kohli, Gautam Gambhir, Suresh Raina, Rohit Sharma}
false
null {NULL VALUE}
{Sachin Tendulkar, Dhoni, Sehwag, Yuvraj Singh, Virat Kohli, Gautam Gambhir, Suresh Raina, Rohit Sharma}
false
Suresh Raina
[]{EMPTY LIST}
false
Suresh Raina
null
false


import java.util.*;
class EqualsAnyStrings
{
    public static void main(String s[])
    {
        String inputString = "Virat Kohli";
        String[] strings = {"Sachin Tendulkar", "Dhoni", "Sehwag", "Yuvraj Singh", "Virat Kohli", "Gautam Gambhir", "Suresh Raina", "Rohit Sharma"};
        boolean result = equalsAny(inputString, strings);
        System.out.println("The input string \"Virat Kohli\" is equals any one of strings {Sachin Tendulkar, Dhoni, Sehwag, Yuvraj Singh, Virat Kohli, Gautam Gambhir, Suresh Raina, Rohit Sharma} : " +result);

    }


        public static boolean equalsAny(String inputString, String[] strings)
        {
            boolean result = false;
            return result;
    }

}

Doubts

Problems

Topic: Java String Arrays - String Arrays In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App