Tips for heathy life

Tips for heathy life

Kamis, 30 Oktober 2008

FIND OF POSITION any string in the string OTHER in J2SE



I want to share how to FIND OF POSITION any string in the string OTHER. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

String str1="Hello Java Hello Java Hello Java";
System.out.println(str1.indexOf("Java")); //6
System.out.println(str1.indexOf("Java",10)); //17
System.out.println(str1.lastIndexOf("Hello")); //22
System.out.println(str1.lastIndexOf("Hello",10)); //0

0 komentar:

Posting Komentar