I have a class that extends java.util.TreeMap, I was wondering if anyone knows how I can get the root node, and for that manner how I can manually traverse the tree if I want to. When I look at the source for treemap at http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/util/TreeMap.java.html the root node is private, thus I can't neccessarily access it directly, however perhaps there is a way to access it using a combination of the methods already in treemap?
Please don't write any code for me, just point me in the right direction/pseudocode is ok.
You can access private members using reflection. That defeats the purpose of encapsulation in OO languages though. You can learn about reflection in this tutorial from oracle .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.