How to get index of value in array?

前端 未结 7 1006
無奈伤痛
無奈伤痛 2021-01-26 07:37

I have an array like this :

String[] array = { \"Designation1\", \"Designation2\", \"Designation3\" };

If user put \"Designation2\" as input th

7条回答
  •  天涯浪人
    2021-01-26 08:30

    You can do it like this.

    String userinput="Designation2";
    String[] array = { "Designation1", "Designation2", "Designation3" };
    int length=array.length();
    int index=0;
    for(int i=0;i

    And index will give you the array key that user wants. Regards..

提交回复
热议问题