Answers for "string get index of character"

20

character at index of string java

String str = "Grepper";
char ch = str.charAt(0);
//ch is assigned the value of G
Posted by: Guest on June-03-2020
1

find the index of a substring

# To find the index of a substring in another string
# Take for instance, below take two strings: str and substr. 

str="hello world"
substr="world"
 
prefix=${str%%$substr*}
index=${#prefix}
 
if [[ index -eq ${#str} ]];
then
    echo "Substring is not present in string."
else
    echo "Index of substring in string : $index"
fi
Posted by: Guest on April-20-2022
0

string get a letter by index

charAt(index)
Posted by: Guest on April-22-2021

Code answers related to "string get index of character"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language