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/