Home arrow static arrow Java Programming [Archive] - occurances of a smaller string within a bigger
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - occurances of a smaller string within a bigger
This topic has 2 replies on 1 page.

Posts:2
Registered: 8/3/04
occurances of a smaller string within a bigger  
Aug 3, 2004 8:50 AM



 
hello!

If i want to fin the startpositions of String hello within String helloheyhelloheyhelloheyhello

that is 0 ,8 ,16 ,24

How do i do?....I have this:

System.out.println(word.indexOf(word2));

it gets me the first position....

thanks for you help im stuck
 

Posts:19,725
Registered: 9/26/01
Re: occurances of a smaller string within a bigger  
Aug 3, 2004 8:54 AM (reply 1 of 2)



 
Do your own homework, but a clue is in the fact that there is also a method called indexOf(String str, int fromIndex)
 

Posts:2
Registered: 8/3/04
Re: occurances of a smaller string within a bigger  
Aug 3, 2004 9:01 AM (reply 2 of 2)



 
thanks a lot...yeah its actually my homework but sometimes you need a push...

Andy
 
This topic has 2 replies on 1 page.