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 / Databases / December 2005

Tip: Looking for answers? Try searching our database.

How to write narray Tree? example pls

Thread view: 
sanny.h@gmail.com - 28 Dec 2005 02:11 GMT
Hi all,
      Thank you all for having this group.
       I am new to the world of java.
       I want to write a java program were the strings are stored in a
tree (not binary tree).
For example
1) "APPLE" -> "RED"
2) "APPLE" -> "WHITE"
3) "APPLE" -> "USA" ->"RED"
4)"APPLE" -> "USA" -> "WHITE"
5) "APPLE" -> "USA" -> "NYC" -> "RED" ............soon

So APPLE will have 3 child nodes (RED,WHITE,USA). Child node USA will
have 3 child nodes (RED,WHITE,NYC) , NYC has RED ......soon.

If not tree any other method that i can achieve this?

Thanks in advance.
sanny.
IchBin - 28 Dec 2005 02:55 GMT
> Hi all,
>        Thank you all for having this group.
[quoted text clipped - 15 lines]
> Thanks in advance.
> sanny.

I guess by tree you mean a visual tree. Say a SWING JTree or AWT Tree.

I can point you to samples that will get you going. Not sure what docs
you are using but first hear are the important ones you will need to
learn from.

Current 1.5 Docs
http://java.sun.com/j2se/1.5.0/docs/

Current 1.5 APIs
http://java.sun.com/j2se/1.5.0/docs/

The Java Language Specification, Third Edition
http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html

The Really Big Index, A list of all content pages in the The JavaTM
Tutorial
http://java.sun.com/docs/books/tutorial/reallybigindex.html

The Java Developers Almanac 1.4
http://javaalmanac.com/

For samples of JTree look here..
http://javaalmanac.com/cgi-bin/search/find.pl?words=JTree

Also I have more references at my website.
http://weconsultants.servebeer.com/JHackerAppManager/Portal?xpc=1$@4$@1$@19

A good reference is at Roedy Greens web site.
http://mindprod.com/jgloss/jgloss.html
http://mindprod.com/jgloss/jtree.html

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

sanny.h@gmail.com - 28 Dec 2005 05:10 GMT
Hi IchBin,
            Thanks for the quick reply. is thr any other way by which
i can get the code without using JTree (swing or AWT). ?

The goal is to build a tree of "strings" and thn traverse the tree to
get the required leaf.
i mean the input may be "APPLE RED" or "APPLE USA WHITE" based on the
input i need to construct the tree.

Any pointers to the same will be helpful.

Thanks
Sanny
Thomas Hawtin - 28 Dec 2005 14:09 GMT
>         I want to write a java program were the strings are stored in a
> tree (not binary tree).
[quoted text clipped - 7 lines]
> So APPLE will have 3 child nodes (RED,WHITE,USA). Child node USA will
> have 3 child nodes (RED,WHITE,NYC) , NYC has RED ......soon.

You should probably write a class representing each node of the tree,
along the lines of:

class Node {
    ...
    public Node(String name) { ... }
    public String getName() { ... }
    public Set<Node> getChildren() { ... }
    public void addChild(Node child) { ... }
}

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



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.