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. I am a B. Tech. (ECE) student, can i also give scj
View Tutorial          By: Sneha Agarwal at 2013-07-11 08:10:17

2. how about the field is multiple times?
is i

View Tutorial          By: g at 2010-10-11 01:09:59

3. right to point.. thanks man
View Tutorial          By: manish at 2012-07-28 15:01:26

4. hi ,
i am a beginner in java. please tell m

View Tutorial          By: aun at 2011-11-18 06:47:56

5. hai sir... this is ROSHAN I am searching for voice
View Tutorial          By: roshan at 2013-09-25 08:12:55

6. Thanks for a great post. Solved a problem for me i
View Tutorial          By: Mark at 2013-01-08 07:00:47

7. Hi..thx for the hadoop info..i m learning hadoop..
View Tutorial          By: Kirti at 2015-10-26 11:42:02

8. HELP ME HOW TO ANALZE THE PROGRAM??????????
View Tutorial          By: MICHELLE FLORES at 2009-01-21 23:24:52

9. Seems to be the best tutorial on this topic. At le
View Tutorial          By: Bob Nickson at 2008-08-26 02:50:29

10. Please some one send me the 6th program developed
View Tutorial          By: mounika at 2008-04-25 02:49:56