Retrieving an element from array list in Android?

后端 未结 6 2058
醉话见心
醉话见心 2021-02-01 07:16

I am trying to implement voice recognition code in Android. How do I get an element at a particular position from array list in Android? I tried converting arraylist

6条回答
  •  猫巷女王i
    2021-02-01 07:46

    In arraylist you have a positional order and not a nominal order, so you need to know in advance the element position you need to select or you must loop between elements until you find the element that you need to use. To do this you can use an iterator and an if, for example:

    Iterator iter = list.iterator();
    while (iter.hasNext())
    {
        // if here          
        System.out.println("string " + iter.next());
    }
    

提交回复
热议问题