mardi 10 novembre 2015

Check if value is there in Static array : Java

I have the following class :

public class ValueHolder {
    private String columnName;
    private int width;
    private String defaultColumnStyle;

    public String getDefaultColumnStyle() {
        return defaultColumnStyle;
    }

    public void setDefaultColumnStyle(String defaultColumnStyle) {
        this.defaultColumnStyle = defaultColumnStyle;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public ValueHolder(String columnName, int width, String cellStyle) {
        this.columnName = columnName;
        this.width = width;
    }

    public ValueHolder(String columnName, int width, String cellStyle, String defaultColumnStyle) {
        this(columnName, width, cellStyle, defaultColumnStyle, null);
    }

    public ValueHolder(String columnName, int width, String cellStyle, String defaultColumnStyle, String dataFormat) {
        this.columnName = columnName;
        this.width = width;
        this.defaultColumnStyle = defaultColumnStyle;
    }

}

and the following

public class StaticArrayValues {

    public static ValueHolder[] TEST_VALUES = new ValueHolder[] {

            new ValueHolder("test Name", 4498, "testvalue"), new ValueHolder("Last Name", 4498, "testvalue"),
            new ValueHolder("test ID", 4498, "testvalue"), new ValueHolder("ID Value", 4498, "testvalue") };

    public static void main(String[] args) {

        String testValue= "First Name";

        // How do i check if testValue is there in  TEST_VALUES
        /*if(){

        }*/

    }

}

How do i check if "First Name" is there in TEST_VALUES ?

I am sure it is the basic question but still i am not able to figure out the way :(.

could some one help me please?

Aucun commentaire:

Enregistrer un commentaire