Comment on Tutorial - indexOf( ) and lastIndexOf( ) in Java By Hong



Comment Added by : vallabh

Comment Added at : 2014-10-04 17:44:18

Comment on Tutorial : indexOf( ) and lastIndexOf( ) in Java By Hong
u can try this out it will satisify u:)
import java.io.*;
public class lastindexof
{
public static void main(String[] args) throws IOException
{
String mystr;
int cou=0;
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("enter the string");
mystr=bf.readLine();
System.out.println("enter the string ");
String st=bf.readLine();
for(int i=0;i<mystr.length()-1;i++)
{
if(mystr.indexOf(st)!=-1)
cou++;
}
System.out.println(" character at position is=" +mystr.indexOf(st));
System.out.println(cou);;
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Yeah..it's very good example....
View Tutorial          By: Packiyaraj.T at 2010-07-22 22:39:48

2. Good explanation on how to parse.

Y

View Tutorial          By: Sravan at 2010-10-05 05:16:39

3. hai, i tried the abvoe code, m getting the follwin
View Tutorial          By: charan at 2011-10-20 12:59:59

4. Thank you for Very good article.
View Tutorial          By: Pakornsak S at 2010-02-08 04:35:05

5. I'm sorry but your closing statement...

View Tutorial          By: Al Scherer at 2009-09-15 09:33:24

6. Thanks.. worked perfectly :)
View Tutorial          By: DJ at 2012-04-05 19:40:43

7. give me some logics for programs as soon as possib
View Tutorial          By: nari at 2011-12-07 18:28:03

8. it is working....great
View Tutorial          By: mahesh maduranga at 2011-03-27 23:01:57

9. i found this tutorial very useful... i need to kno
View Tutorial          By: Anonymous at 2009-04-14 21:09:20

10. Thanks bro...you save me from a great problem...ve
View Tutorial          By: Tishan at 2012-07-09 09:14:07