现在有一个需求,在一段字符串中查找出某段内容第N次出现的位置
比如说:在字符串 "Hello World"
中查找"l"
第二次出现的位置
具体代码如下
public static void main(String[] args) {
String str = "Hello World"; // 定义字符串 "Hello World"
String key = "l"; // 定义需要被查找的字符串
现在有一个需求,在一段字符串中查找出某段内容第N次出现的位置
比如说:在字符串 "Hello World"
中查找"l"
第二次出现的位置
具体代码如下
public static void main(String[] args) {
String str = "Hello World"; // 定义字符串 "Hello World"
String key = "l"; // 定义需要被查找的字符串