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



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. Create a lexical analyzer of the C- programming la
View Tutorial          By: lucky at 2011-05-06 23:05:22

2. Most Our friends ask About error occurred during t
View Tutorial          By: Chala G. at 2015-01-13 16:52:10

3. too good post....very easy to understand
View Tutorial          By: Rahul at 2013-03-04 17:09:58

4. This tutorial is so simple, often we dont need to
View Tutorial          By: NIrjhar at 2011-12-12 03:29:52

5. sir i am mca student. i can choose my flatform is
View Tutorial          By: sridevi at 2012-06-06 10:21:39

6. plz can u give me code for database connectivity f
View Tutorial          By: nilam at 2012-03-15 12:54:07

7. "Type safety: The method add(Object) belongs
View Tutorial          By: WalterB Ntuli at 2010-04-09 01:51:17

8. thanks it is nice
View Tutorial          By: Ajay at 2011-07-22 03:44:05

9. I'm trying to learn navigating between activities.
View Tutorial          By: Ben at 2012-01-17 23:42:38

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

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