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. Actually, the given accuracy just barely exceeds w
View Tutorial          By: William Fraser at 2015-06-07 16:37:52

2. How can i download the comm.API .
pls tel

View Tutorial          By: Sajeer kc at 2015-01-16 04:12:28

3. I am receiving an error as
Error java.lan

View Tutorial          By: pablo at 2014-08-03 16:10:55

4. not bad
View Tutorial          By: JUST_PREET at 2013-03-06 11:37:15

5. The code gives the following exception :-
<

View Tutorial          By: Lourdu Felix at 2009-01-26 03:37:53

6. just I am need of some of the soft copy related to
View Tutorial          By: shani at 2015-08-12 06:01:05

7. good site for buggners
View Tutorial          By: sivannaadhbaazi karampudi at 2011-12-01 15:37:55

8. Hi.. Everyone... i would like to send and received
View Tutorial          By: Michael at 2011-01-29 23:43:23

9. hey...i have a problem getting the system date in
View Tutorial          By: angel at 2010-04-03 09:27:38

10. Hi Ramlak,

I tried to use the datab

View Tutorial          By: Braj at 2009-02-07 03:31:13