List<String> list1 = new ArrayList<String>(words.length);
List<String> list2 = new ArrayList<String>(word.length);
for(String x: list1){
for(String y: list2){
if(x.equalsIgnoreCase(y)){
System.out.print(list1.indexOf(x) +" "+ ",");
}
}
}
索引对于这个功能,运行之后将其删除最后一个逗号,输出将是2,5,7 .... 9, 我的问题是如何删除最后一个逗号?如何当我打印出来的ArrayList
的[移除循环打印输出JAVA最后一个逗号]可能重复(http://stackoverflow.com/questions/18297551/remove-last-comma -from-loop-printouts-java) –
I [写下这个确切的代码](http://stackoverflow.com/a/22585042/2071828)。希望能帮助到你。 –