Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java find all of letter in string

String stringName = "Hello";
String characterToFind = "l";
//This example will find all the Ls in this string and will print the index of
//it as soon as it is detected

for(int i = 0; i < stringName.length(); i++){
  if(stringName.substring(i, i+1).equals(characterToFind)){
    System.out.println(characterToFind + "found at " + i);
  }
  
}
Comment

PREVIOUS NEXT
Code Example
Java :: 8.1.1. Declaring an Array&para; 
Java :: create new empty list java 
Java :: android get distance between two locations kotlin 
Java :: java copy file 
Java :: How to determine whether a graph contains a cycle, in Java? 
Java :: timestamp java jpa 
Java :: how to get data from radio group in android 
Java :: java break string into words 
Java :: date format in java 
Java :: java how to convert string to int 
Java :: map string string to java object 
Java :: how to check if the file has remaining without reading from it java 
Java :: java replace first occurrence of substring 
Java :: java arraylist deep copy 
Java :: long vs int java 
Java :: how to move a marker on google maps in android studio 
Java :: react The href attribute is required for an anchor to be keyboard 
Java :: java get first day of the week 
Java :: from date to string 
Java :: how to fill a 2d array in java 
Java :: parse object to int java 
Java :: send action bar message bukkit 
Java :: how to conver string to int 
Java :: java print type of variable 
Java :: convert two bytes to int java 
Java :: How to draw Bezier Curve in Android 
Java :: importing all java libraries 
Java :: enum java 
Java :: navigation view menu color android 
Java :: maven artifact 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =