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. Hi Rahul,
I am struggling to send

View Tutorial          By: sravani at 2011-02-11 22:56:58

2. Hi, from where i can download javax.comm API jar f
View Tutorial          By: Chandra at 2008-11-19 11:49:46

3. sir i m getting chat server started bt how a clien
View Tutorial          By: ashu at 2010-11-02 08:13:00

4. thank you, this best for student like us,
View Tutorial          By: Srinath at 2012-05-12 15:04:03

5. nice
View Tutorial          By: srfds at 2012-05-28 09:25:15

6. #include<iostream>
#include<conio.

View Tutorial          By: XavioR at 2011-01-31 00:53:11

7. Such a nice site for clear and explains the concep
View Tutorial          By: Sandeep at 2011-05-22 06:34:42

8. can i ask a program that will compute a order from
View Tutorial          By: mjae at 2011-09-12 08:02:46

9. easy to understand and it helped me a lot in prepa
View Tutorial          By: shandini at 2011-04-14 13:14:33

10. i am getting an exceptions... pls help me..

View Tutorial          By: FEBI at 2014-03-08 06:01:44