I read about how TreeSet is slower than HashSet, (that adding elements into a TreeSet is slower) so i made a performance test, i\'m trying to find out if it\'s better to add
0) JVM benchmarking is really complicated. Almost always you're measuring not what you're thinking you are measuring. There's http://openjdk.java.net/projects/code-tools/jmh/ for microbenchmarking from guys from Oracle. And you may try some benchmarking frameworks and guides.
JIT compiler warmup, initial memory allocation, garbage collector and a LOT of other things may invalidate your benchmark.
1) See also Hashset vs Treeset regarding your first question
2) Set
That's how it works. You declare treeSet as Set. Set does not extends NavigableSet. You may explicitly cast if you want to. But if you want to access NavigableSet methods why wouldn't you declare treeSet as NavigableSet
Set treeSet = new TreeSet();
Integer lower = ((NavigableSet) treeSet).lower(); // thus should work