Results 1 to 5 of 5
- 03-04-2010, 04:56 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 7
- Rep Power
- 0
find index of string in another string
I need to write a method that finds the index of a string 2, inside string 1. For example, if the strings ("mississippi", "ss") are passed, it would return the index of where "ss" is in the string "mississippi" So in this case it would return a 2.
I cannot use the String.indexOf(String) method.
Thanks!
- 03-04-2010, 05:02 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Use substring(). Read the Java API for more details.
- 03-04-2010, 08:19 AM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,422
- Blog Entries
- 7
- Rep Power
- 17
- 03-04-2010, 08:29 AM #4
Member
- Join Date
- Mar 2010
- Posts
- 7
- Rep Power
- 0
I would do this, but if you read my post you would read "I cannot use the String.indexOf(String) method."
I initially had the SAME thought as you though! My professor is trying to make us think outside of the box a little and create our OWN methods to do some simple tasks that already have methods created for these tasks. I think I got it figured out though, if so I will mark as solved.
- 03-04-2010, 10:14 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,422
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Find index position of every word in a String
By pentace in forum New To JavaReplies: 6Last Post: 06-28-2009, 08:26 PM -
Find a number from a string
By florentp in forum New To JavaReplies: 2Last Post: 03-20-2009, 09:01 PM -
Noob here, trying to access index in string
By madmax2006 in forum New To JavaReplies: 14Last Post: 03-08-2009, 05:08 PM -
Find java objects in a given string.
By sarathi in forum New To JavaReplies: 3Last Post: 03-06-2009, 08:42 AM -
Find and replace ( in a String
By hamish10101 in forum New To JavaReplies: 6Last Post: 01-17-2008, 05:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks