wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes how to creat a searching code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to creat a searching code?" Watch "how to creat a searching code?" New topic
Author

how to creat a searching code?

Jose Cisse
Greenhorn

Joined: Mar 20, 2006
Posts: 28
here s my inventory class:

now i want creat a "searchforprice", in order to type a name get its price... ...so what do i need to add in these codes?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18509
    
  40

Take a shot at it first, figuring it out is part of the learning process... We can't give you a hint, if we don't know where you are stuck.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jose Cisse
Greenhorn

Joined: Mar 20, 2006
Posts: 28
basically i m trying to make a program for books inventory... ...
and this is my inventory class shown above~~~
as you see, i got some codes for listing book, adding new book, removing.. ...and so on... ...
and now i want to write some codes for searching: when i enter name of book, its price ll be shown... ...
so firstofall, i need to create such searching thing in my inventory class.. ...
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
I think his point was that you should try it yourself, and ask specific questions. Look up linear search and binary search algorithms and try to implement one of those, and if you have specific questions ask. Linear search is easier to start off with. Your question is to general to be able to properly answer it without doing the work for you.


A linear search is very simple. Start at the beggining of the data structure, see if it is what you are looking for, if not move to the next element. Rinse and repeat until you get to the end of the ArrayList.
[ March 22, 2006: Message edited by: Rusty Shackleford ]

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to creat a searching code?
 
Similar Threads
adding items to arraylist through constructor
how to deal with this error???
another changing method problem
Accessing objects from Collection
HELP NEEDED~~