Java - get element position in array

后端 未结 4 1855
谎友^
谎友^ 2021-01-03 20:47

I\'m familiar with the ways I can get an element position in array, especially the ones showed here: Element position in array

But my problem is I can\'t figure out

4条回答
  •  离开以前
    2021-01-03 21:52

    Hope this will help you.change your code like this:

    if (listPackages.contains(current_package)){
    int position=listPackages.indexOf(current_package);
    }
    

    Also if you will make position variable as global you can access its value outside this block of code. :)

提交回复
热议问题