[在字符串[duplicate]的数组内的字符串的索引

问题描述 投票:0回答:1

我如何在其中包含"10"的索引

private static String[] faces  = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };

使用更少的Java代码?

java arrays indexing
1个回答
2
投票

String[]包裹在List中,然后使用indexOf

int indexOf10 = Arrays.asList(faces).indexOf("10");
© www.soinside.com 2019 - 2024. All rights reserved.