Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Generics and Linked Lists

Thread view: 
GreenMountainBoy - 19 Feb 2007 04:56 GMT
sorry for xcrosslist - just did it once.

Generics Linked List -

I am trying to find an example or partial example of how you could
write a program that takes only one first name per node, and that you
can later search for one name. No duplicates.

Thanks for you thoughtful help. It is much appreciate.

GreenMountainBoy
Boaz.Jan@gmail.com - 19 Feb 2007 12:30 GMT
On Feb 19, 6:56 am, "GreenMountainBoy" <william.fi...@gmail.com>
wrote:
> sorry for xcrosslist - just did it once.
>
[quoted text clipped - 7 lines]
>
> GreenMountainBoy

its kindof vauge... can you explain what you want execly?
first name per node?
search for one name no duplicates? you want first name to act like a
uniqe key? your list node are String firstName?
if you want no duplicates and your nodes only contain the firstname i
would suggest using h hashmap
the key will be the firstname string value and the value of the node
wll be the "Entity" which contains the first name
with hashmap you cant have duplicate keys... but its not a linked list
as you mentioned but it is genereic

if you want to use a simle linked list you may manage the add method
so it wont add any object that conatins the same first name (implement
Comparable for you node so your code will be clean)
and then you can search for a first name simply by iterating the list
(if thats what you wanted)

for more exact help i will need more info about what you are trying to
do
GreenMountainBoy - 19 Feb 2007 18:06 GMT
On Feb 19, 7:30 am, "Boaz....@gmail.com" <Boaz....@gmail.com> wrote:
> On Feb 19, 6:56 am, "GreenMountainBoy" <william.fi...@gmail.com>
> wrote:
[quoted text clipped - 30 lines]
> for more exact help i will need more info about what you are trying to
> do

I am trying to implement a linkedList program using Generics -
LinkedList with an iterator. The only data in each node is a single
string. I need to be able to add a string to a new node, and also have
a separate snippet which allows for a search of the linked list (using
Generics LinkedList structure) for a match on the string stored in one
of the nodes - if no match is found, return "NO MATCH" -
this must be done using the LinkedList from the Generics utility
class.

Please see if this helps and give me a clue as to how to get started.

Thank you,

GreenMountainBoy
Mark Rafn - 19 Feb 2007 20:02 GMT
>I am trying to implement a linkedList program using Generics -
>LinkedList with an iterator.

Why not use java.util.LinkedList<String>?  Or if this is homework, why not
look at the source for java.util.LinkedList to learn (steal) from?

>Please see if this helps and give me a clue as to how to get started.

Start by telling us what you've tried so far, and ask very specific questions
about where you're stuck.  This group sucks at writing your homework for you,
on purpose.
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>
sdemchenko@gmail.com - 19 Feb 2007 17:07 GMT
Does not java.util.LinkedHashSet do what you need?
mickey - 19 Feb 2007 20:29 GMT
On Feb 19, 9:56 am, "GreenMountainBoy" <william.fi...@gmail.com>
wrote:
> sorry for xcrosslist - just did it once.
>
[quoted text clipped - 7 lines]
>
> GreenMountainBoy

hi... GEnerics Linked List seem to be tough to me at the very
beginning ....still i have no deeper understanding of the how to make
program that takes only one first name per node
CAN u plzz suggest me from where to refer this topic ...any book or
any tutorial that can build idea regarding  linked list and other
topics ..
plzz reply me regerding this///
mailto: mickey_thukral@yahoo.com
GreenMountainBoy - 19 Feb 2007 21:22 GMT
> On Feb 19, 9:56 am, "GreenMountainBoy" <william.fi...@gmail.com>
> wrote:
[quoted text clipped - 19 lines]
> plzz reply me regerding this///
> mailto: mickey_thuk...@yahoo.com

I have the code working - but the iterator over the list bombs out
every time
I do iterator.next().equals(strng) - this is where I am looking for
the name i put in the LinkedList of generic type.

Thanks, man.
Mark Rafn - 19 Feb 2007 22:07 GMT
>I have the code working - but the iterator over the list bombs out
>every time I do iterator.next().equals(strng) - this is where I am looking
>for the name i put in the LinkedList of generic type.

Show us some code, and tell us what exception you're getting.  "I do something
and it doesn't work" doesn't give much room to help.
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>
GreenMountainBoy - 21 Feb 2007 01:54 GMT
> >I have the code working - but the iterator over thelistbombs out
> >every time I do iterator.next().equals(strng) - this is where I am looking
[quoted text clipped - 4 lines]
> --
> Mark Rafn    d...@dagon.net    <http://www.dagon.net/>

thanks for help - i think i have it figured out!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.