Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

what method is use for getting the index position of a character of a string in java

// If you want to get the index position of a character in a String, use this method:
.charAt( /*Args int*/ )
// Here's a practial example:
String str = "Grepper";
char ch = str.charAt(0);

// If you want to get the index position of a word/char in a string(a Phrase/Sentence), you could use this method:
.indexOf( /*Args Str*/ )
// Here's a practial example:
String myStr = "This is just an example Sentence";
System.out.println(myStr.indexOf("example"));
Comment

java string character at index

/*
If you want to get the index position of a character in a String,
use this method:.charAt( <index> )
*/  
// Here's a practial example:
String str = "Grepper";
char ch = str.charAt(0);
// output: G 

/* If you want to get the index position of a word/char in a string(a Phrase/Sentence), 
you could use this method:.indexOf( <Args Str> )
Here's a practial example:
*/ 
String myStr = "This is just an example Sentence";
System.out.println(myStr.indexOf("example"));
// output: 16
Comment

PREVIOUS NEXT
Code Example
Java :: sound file java 
Java :: how to get input of local date type java 
Java :: java concatenate strings 
Java :: java newinstance alternative 
Java :: list java 
Java :: java difference hashmap hashtable 
Java :: java boucle for 
Java :: how to replace an element in array in java 
Java :: how to find sum of the digit of the numbers in java 
Java :: java ceil 
Java :: jcolorchooser in java 
Java :: how to create set java 
Java :: on item click listener for recyclerview adapter 
Java :: write message in file java 
Java :: java set operations 
Java :: parcourir un string java 
Java :: Java get color from rgb values 
Java :: Simple While Loop Java Example 
Java :: java calendar 
Java :: Java How to use Queue? 
Java :: initializing list in java 
Java :: java print a line seperate by space 
Java :: ClassNotFoundException: org.springframework.ui.freemarker.FreeMarkerConfigurationFactory 
Java :: hdfs hadoop JobClient.java:876 error 
Java :: 2d array length in java 
Java :: using a SnackBar on androidstudio 
Java :: android java show hide keyboard in AndroidManifest 
Java :: flutter webview plugin background transparent 
Java :: return class name java 
Java :: java add element to map 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =