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. @mahesh yes you can use this to connect to any db
View Tutorial          By: Rita sen at 2012-01-05 05:18:13

2. excellent, very clear, thx!!!
View Tutorial          By: ma at 2010-04-07 07:42:47

3. Nice Work... Keep it..
View Tutorial          By: Ashok at 2010-02-28 05:12:31

4. if suppose i am having connection pool max size 30
View Tutorial          By: Shrikant at 2012-07-20 12:09:33

5. Actually i had downloaded all the files but it thr
View Tutorial          By: bornwithpowers at 2009-11-11 04:48:21

6. nice overview on struts.....
View Tutorial          By: priyanka at 2010-08-23 00:13:33

7. Thank you so much. I have migrated from the .NET t
View Tutorial          By: kanika at 2011-05-31 12:23:33

8. main is not needed for a simple program...

View Tutorial          By: manoj at 2012-05-29 17:46:08

9. Hi
I have final project whit sms program.
View Tutorial          By: AliPour at 2011-09-11 16:51:19

10. Hello sir pls send me
com.sun.speech.freett

View Tutorial          By: shanthi at 2013-03-22 11:18:56