Sponsered Links
Categories
Sponsered Links

Java String indexing example

 

 This is a simple Java String indexing example.

 public class StringIndex {

public static void main(String args[]){
String str = "jsp servlet tutorial";
int a = str.indexOf('h');
System.out.println("Index of 'h' in String 'str' is: " + a);    
System.out.println("Index of 's' in String 'str' is: " + str.indexOf("s"));
System.out.println("Index of 'servlet' in String 'str' is: " + str.indexOf("servlet"));
}
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved