by
0 31
3
5
2,767
1
Top 1% !
Popular
Famous
Specified
MultiPlatform
Popularity: 5998th place
No tags for this snippet yet.
Languagecoffeescript
Languagejava
LicenseMIT_X11

solution needed

What will be the output of the following snippet of code? 

public class Test {
public static void main(String[] args) {
TreeMap<Integer,String> map  = new TreeMap<Integer,String>();
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
map.put(4, "four");

System.out.print(map.higherKey(2));
System.out.print(map.ceilingKey(2));
System.out.print(map.floorKey(1));
System.out.print(map.lowerKey(1));
}
}
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/250850/solution-needed?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
Please include headers, import java.util.TreeMap; //Returns: 321null Explaination; 1) higherKey: returns the least key strictly greater than the given key, or null if there is no such key. 2) ceilingKey: returns the least key greater than or equal to the given key, or null if there is no such key. 3) floorKey: returns the greatest key less than or equal to the given key, or null if there is no such key. 4) lowerKey: returns the greatest key strictly less than the given key, or null if there is no such key.

Question

If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus