Java: Find the index of a String in a list

前端 未结 1 915
一向
一向 2021-01-18 08:58

I have a list:

public static  List codes = new LinkedList(Arrays.asList(
            \"Zero\",
            \"One\"
            ))         


        
1条回答
  •  半阙折子戏
    2021-01-18 09:36

    The reverse of codes.get() is indexOf(Object obj) method

    Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

    codes.indexOf("One");
    

    0 讨论(0)
提交回复
热议问题