String search methods indexOf and lastIndexOf

Reply

Join Date: Mar 2009
Posts: 3
Reputation: enitsirc is an unknown quantity at this point 
Solved Threads: 0
enitsirc's Avatar
enitsirc enitsirc is offline Offline
Newbie Poster

String search methods indexOf and lastIndexOf

 
0
  #1
Mar 13th, 2009
I need help on this: Write your own versions of String search methods indexOf and lastIndexOf.

Hope you could help.thanks.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: String search methods indexOf and lastIndexOf

 
0
  #2
Mar 13th, 2009
I don't think so, but java docs can. Check the java docs for the methods and try implement the methods yourself those are some pretty basic ones.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 3
Reputation: enitsirc is an unknown quantity at this point 
Solved Threads: 0
enitsirc's Avatar
enitsirc enitsirc is offline Offline
Newbie Poster

Re: String search methods indexOf and lastIndexOf

 
0
  #3
Mar 13th, 2009
i'm a beginner on programing that is why i dont know much about this.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: String search methods indexOf and lastIndexOf

 
0
  #4
Mar 13th, 2009
Help has already been offered if care enough to look for it.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: String search methods indexOf and lastIndexOf

 
0
  #5
Mar 13th, 2009
maybe you don't know much (yet) but this is exactly the reason you are given assignments like this, to get to know the syntaxis and regulary used methods and to create your own implementation of them.

asking us to just give you the code would mean that in a week, you still have to say "I don't know much, which is why I need help".

try to understand what indexOf() and lastIndexOf() do:
a String - object can be seen as an array of chars, so the indexOf("substring") will give you the 'index' of the start of the given substring within the original String.

for instance:
  1. String ob = "the first String";
  2. System.out.println("place: " + ob.indexOf("St"));
  3. System.out.println("place: " + ob.indexOf("notPresent"));

just run this code, see what it does, and interprete the results you get.

I take it that lastIndexOf("") will be quite clear after the answers you've already been given.

once you figured out what the code I've posted above does, it should be quite easy to write a new implementation of this methods
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC