Java: Find the index of a String in a list

前端 未结 1 893
一向
一向 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)
提交回复
热议问题