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



Ask a Question

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. Thanks for the above description, but pls let me k
View Tutorial          By: Amit Goyal at 2009-09-25 05:33:10

2. This is the coding that I wanted...
This is

View Tutorial          By: Damith at 2012-05-16 17:26:10

3. hi,
i have tried to download the sun api fr

View Tutorial          By: raghu at 2009-01-07 05:45:33

4. how i can used inheritence ?
View Tutorial          By: samee at 2008-02-16 12:54:27

5. Hello,
I want to send an mulitple sms using

View Tutorial          By: Fionna at 2009-07-10 01:02:11

6. I am using VS 2010 Express and MS Excel 2007 where
View Tutorial          By: Alphin at 2012-07-06 10:57:07

7. There are so many posts about the same problem (i
View Tutorial          By: Matt at 2010-04-30 09:52:16

8. your tutorial is very helpful...
i was hopi

View Tutorial          By: Zero17 at 2009-08-15 09:17:16

9. Sir, this is very helpful for students and profess
View Tutorial          By: Pankaj Choudhary at 2010-10-19 00:24:36

10. not working on mozila firefox 3.1. I tested it.
View Tutorial          By: sushma at 2009-10-08 00:07:47