如何返回字符串中多个指定字符的位置

如题所述

public static void main(String args[]) {
String str = "12&32&位置&yutye";
System.out.println("&在字符串中出现的位置分别为:");
for(int i=-1; i<=str.lastIndexOf("&");++i)
{
i=str.indexOf("&",i);
System.out.print(i+"\t");

}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-05-08
根据位置截取,进行返回
相似回答