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. Hi Rima,

Check out http://forums.su

View Tutorial          By: Ramlak at 2008-12-28 03:00:01

2. Thanks. Your post was clear and worked perfectly a
View Tutorial          By: Suma at 2009-03-05 09:40:08

3. hi Ashray P Shetty,
I'm getting the followi

View Tutorial          By: Balaji at 2010-11-25 14:16:23

4. Can you explain when the user input through the ab
View Tutorial          By: mujmil at 2008-02-11 18:46:00

5. i will make to try for rms :)
View Tutorial          By: sebo at 2010-05-20 07:38:28

6. Imports Excel = Microsoft.Office.Interop.Excel

View Tutorial          By: Nilesh at 2014-12-01 13:45:25

7. Hi,

This is very nice tutorial to

View Tutorial          By: Robvandam at 2010-05-03 00:29:38

8. Hi guys
i am a beginer in java.. pls help

View Tutorial          By: Jeevan at 2009-12-19 09:35:06

9. thank you sir
View Tutorial          By: ramya at 2010-01-11 00:42:05

10. This works great, just remember to add <uses-pe
View Tutorial          By: Nick at 2012-06-20 07:37:15