aspose file tools*
The moose likes Beginning Java and the fly likes search methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "search methods" Watch "search methods" New topic
Author

search methods

Tony Cossie
Greenhorn

Joined: Mar 11, 2001
Posts: 13
Hi,
Could anyone give me the source code for a linear search method for an array of Strings? and a binary search one too please.
Or where i could get to look at one on a web site maybe.
Thanks for your time
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
There are some handy methods in the java.util.Arrays class ...


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Tony Cossie
Greenhorn

Joined: Mar 11, 2001
Posts: 13
Originally posted by Marilyn deQueiroz:
There are some handy methods in the java.util.Arrays class ...

I have to write the code for it, so i will be able to understand how it works. I've found ones for searching arrays of ints but when i change them they don't work for Strings.
Kaspar Dahlqvist
Ranch Hand

Joined: Jun 18, 2001
Posts: 128
Hi!
Unpack the source code (src.jar) in your jdk and look at the code in class Arrays. (Hopefully it is implemented in java and not in C or such...).
//Kaspar
Tony Cossie
Greenhorn

Joined: Mar 11, 2001
Posts: 13
eh how do i do that? Nobody could give me any source code?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The source comes with the jdk. It is in a file named src.jar. Just open that file with WinZip or whatever zip utility that you have and extract the .java file that you want to read.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
Don't get me started about those stupid light bulbs.
 
subject: search methods