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. nice one its very useful
View Tutorial          By: jhejhe at 2010-02-21 05:03:50

2. Really just brilliant...thanks
View Tutorial          By: Ash Singh at 2011-02-21 04:47:20

3. Do the serialized output is displayed in the file
View Tutorial          By: Atihs at 2012-11-17 02:38:52

4. I tried this with HttpUnit (using the custom Hostn
View Tutorial          By: Michael Gower at 2012-01-04 17:40:00

5. gud example, we welcome you
View Tutorial          By: jasim Khalid almurakh meherbani at 2010-09-20 03:14:25

6. pls send more tutorial on my id
View Tutorial          By: vipin at 2012-11-17 07:23:49

7. haii...
I am Ahmed , i am in 3rd btech ,

View Tutorial          By: Ahmed at 2014-08-09 06:30:11

8. Hi,

Can we use this fix.php on the

View Tutorial          By: Chriz at 2010-07-05 09:22:57

9. fantastic explaination about XML parsers
View Tutorial          By: smitha at 2011-05-15 04:53:00

10. thank's for the info.. i've learned a lot.. now, i
View Tutorial          By: farah talabo at 2012-01-08 23:55:14