Hi All

I am new to java. I am facing a problem
I want to compare a string to a set of strings,
For example there is variable string x, If the value String X matches to String A , String B, String C then run the particular code otherwise do not run anything and come out of the loop.

My Code is:

    if((!X.equals("IND"))&&(!X.equals("AJD"))&&(!X.equals("BE"))){
    if (X.equals("IND")) {

        try {
            System.out.println("Form Type dropdown contains Individual");
        } catch (AssertionError e) {
            e.printStackTrace();
        }
    }

    if (X.equals("ADJ")) {
        try {

            System.out.println("Form Type dropdown contains Adjuster");
        } catch (AssertionError e) {
            e.printStackTrace();
        }
    }

    if (X.equals("BE")) {

        try {

            System.out.println("Form Type dropdown contains BE");
        } catch (AssertionError e) {
            e.printStackTrace();
        }
    }
    }else{
        System.out.println("Drop Down value does not match Individual, BE, and Adjuster");
    }
}

But os not wroking as desired ....:(
Please help!!!
Thanks in Advance...

simple use if...elseif ladder to get output.
Like:

if(a.equals(b))
{
}
elseif(a.equals(c))
{
}
elseif(a.equals(d))
{
}
else
{
}

i think its work.

Yeah ...Its working .....Great !!!!
Thank You soo muchh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.