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. Excellent example
View Tutorial          By: Dinesh Patil at 2012-06-19 08:30:48

2. Thanks a lot, a long time I search for solution fo
View Tutorial          By: Jonhnes at 2013-02-16 17:17:47

3. Excellent site.
View Tutorial          By: anonymous at 2011-11-06 12:07:14

4. Hi, Thanks a lot for this wonderful written steps.
View Tutorial          By: Amar at 2012-09-09 17:19:58

5. Hii,,,i have a java server socket program and i wa
View Tutorial          By: prawinmasthan at 2012-01-13 08:38:35

6. Sometimes java do support operator overloading as
View Tutorial          By: Gunjan Srivastava at 2011-07-06 09:14:00

7. I will try
View Tutorial          By: bridges at 2009-09-06 22:09:46

8. i am looking for the samples in java programming u
View Tutorial          By: mary grace leron at 2010-02-18 01:50:50

9. Hi All,
I can send sms successfully from Wi

View Tutorial          By: henrynawaung at 2008-11-14 06:41:13

10. Thank u it helps me alot.....
View Tutorial          By: Ramya at 2012-02-22 10:16:14