Answers for "java treemap"

3

TreeMap in java

import java.util.Map;
import java.util.TreeMap;
public class TreeMapExample
{
   public static void main(String[] args) 
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();    
      tm.put(1000, "Apple");    
      tm.put(1002, "Raspberry");    
      tm.put(1001, "Velvet apple");    
      tm.put(1003, "Banana");    
      for(Map.Entry obj : tm.entrySet())
      {    
         System.out.println(obj.getKey() + " " + obj.getValue());    
      }
   }
}
Posted by: Guest on November-20-2020
0

treemap

>>> def treemap(lst):
...     for i in range(len(lst)):
...         if type(lst[i])==int:
...             lst[i]=lst[i]**2
...         elif type(lst[i])==list:
...             treemap(lst[i])
...     return lst
>>> lst = [1, 2, 3, [4, [5, 6], 7]]
>>> print(treemap(lst))
[1, 4, 9, [16, [25, 36], 49]]
Posted by: Guest on October-30-2021
0

treemap java

TreeMap<Integer, String> x = new TreeMap<Integer, String>();    
tm.put(1, "Hello");
Posted by: Guest on July-31-2021
1

treemap

- TreeMap doesn't have null key and keys are sorted
 Can contain only unique keys and keys are sorted in ascending order.
Posted by: Guest on December-05-2020
0

treemap

def treemap(lst):
    cp = list()
    for element in lst:
        if isinstance(element, list):
            cp.append(treemap(element))
        else:
            cp.append(element**2)
    return cp
Posted by: Guest on October-30-2021
1

treemap in java

TreeSet: Can contain only unique values and it is sorted in ascending order
TreeMap: Can contain only unique keys and keys are sorted in ascending order.
Posted by: Guest on December-05-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language