How to get index of value in array?

前端 未结 7 864
無奈伤痛
無奈伤痛 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:08

    You could just use a for loop

    String[] array = { "Designation1", "Designation2", "Designation3" };   
     Scanner kb=new Scanner(System.in);
        String input=kb.next();
        int index;
        for(int i=0;i

提交回复
热议问题