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. thank u.....
View Tutorial          By: DiptaRanjan at 2013-02-02 14:56:45

2. (i'm a senior PHP programmer, but a newbie in JSP,
View Tutorial          By: LOL at 2013-03-22 08:57:21

3. Don't forget the native type char, which is a 16 b
View Tutorial          By: Ron Stern at 2011-09-18 17:24:12

4. Hi thanks for the example for overriding toString(
View Tutorial          By: Reshma at 2011-05-11 10:46:08

5. Can u tell it can also use for connecting to oracl
View Tutorial          By: Ankur Jain at 2010-08-06 05:31:08

6. This says nothing meaningful.

So ho

View Tutorial          By: Andreas at 2012-09-23 23:01:01

7. I have maked all you said and when I open jsp I am
View Tutorial          By: John at 2013-01-10 14:21:30

8. import java.io.*;
class lastindexof

View Tutorial          By: arya at 2012-11-07 08:37:59

9. thanks for this good example. i got error like (th
View Tutorial          By: anandhi at 2009-12-20 09:32:45

10. i get exception NoSuchPortException. i tried on di
View Tutorial          By: harryjoy at 2009-11-22 05:52:48