There is a second variant of the indexOf
method, which takes a start-index as a parameter.
i = str.indexOf('x');
while(i >= 0) {
System.out.println(i);
i = str.indexOf('x', i+1);
}
More Related Contents:
- Where is Java’s Array indexOf?
- Trying to find all occurrences of an object in Arraylist, in java
- How do I check if a char is a vowel?
- Finding second occurrence of a substring in a string in Java
- Why is indexOf failing to find the object?
- java dice game issues -fast please
- How to send HTTP request in java? [duplicate]
- Deploying my application at the root in Tomcat
- Jsoup Java HTML parser : Executing Javascript events
- Why are my fields initialized to null or to the default value of zero when I’ve declared and initialized them in my class’ constructor?
- Add JAR files to a Spark job – spark-submit
- How to “scan” a website (or page) for info, and bring it into my program?
- Spring Boot 2.0.x disable security for certain profile
- How do I get my Maven Integration tests to run
- Consider defining a bean of type ‘package’ in your configuration [Spring-Boot]
- Garbage collector in Android
- How does Class.forName() work?
- Java Exceptions counter on JVM HotSpot
- Advantage of Local Classes Java
- Why does Stream.allMatch() return true for an empty stream?
- Logging framework incompatibility
- How to programmatically add views and constraints to a ConstraintLayout?
- set timeout for user’s input
- How to enable commit on focusLost for TableView/TreeTableView?
- Create file with given size in Java
- JPA, How to use the same class (entity) to map different tables?
- How can I check if an element exists with Selenium WebDriver? [duplicate]
- Java Scanner doesn’t wait for user input [duplicate]
- How to validate XML against XSD 1.1 in Java?
- How to generate AST from Java source-code? [closed]