The TreeMap and its Methods

 

import java.util.TreeMap;

public class TreeMapMethods {

public static void main(String[] args) {
//creating our tree map
TreeMap<Integer, String> tm = new TreeMap<>();
//Inserting element in our TreeMap
tm.put(22, "this");
tm.put(14, "Invent");
tm.put(24, "blog");
tm.put(20, "on");
tm.put(18, "you");
tm.put(16, "welcomes");
tm.put(12, "Java");

System.out.println("--------------------------------------");
//will give first lowest key in the TreeMap
System.out.println("The first key in the TreeMap");
System.out.println(tm.firstKey());
System.out.println("--------------------------------------");
//will give last/largest key in the TreeMap
System.out.println("The last key in the TreeMap");
System.out.println(tm.lastKey());
System.out.println("--------------------------------------");
//will give lowest key and value associated with it
System.out.println("The First Entry");
System.out.println(tm.firstEntry());
System.out.println("--------------------------------------");
//will give largest key and value associated with it
System.out.println("The last Entry");
System.out.println(tm.lastEntry());
System.out.println("--------------------------------------");
//will give value equal or less than the provided key
System.out.println("The floor entry is");
System.out.println(tm.floorEntry(15));
System.out.println("--------------------------------------");
//will give entry equal or more than the provided key
System.out.println("The Ceiling entry is");
System.out.println(tm.ceilingEntry(15));
System.out.println("--------------------------------------");
//will give key equal or more than the provided key
System.out.println("The ceiling key is");
System.out.println(tm.ceilingKey(15));
System.out.println("--------------------------------------");
//will give key equal or less than the provided key
System.out.println("The floor key is");
System.out.println(tm.floorKey(15));
System.out.println("--------------------------------------");
System.out.println("The head map is");
System.out.println(tm.headMap(16));
System.out.println("--------------------------------------");
System.out.println("The tail map is");
System.out.println(tm.tailMap(16));
System.out.println("--------------------------------------");
System.out.println("The hashcode of Our Map");
System.out.println(tm.hashCode());
System.out.println("--------------------------------------");
System.out.println("If map is empty or not?");
System.out.println(tm.isEmpty());
System.out.println("--------------------------------------");
System.out.println("The size of our Map is");
System.out.println(tm.size());
System.out.println("--------------------------------------");
System.out.println("The sorted Decending KeySet ");
System.out.println(tm.descendingKeySet());
System.out.println("--------------------------------------");
System.out.println("The decending Map ");
System.out.println(tm.descendingMap());
System.out.println("--------------------------------------");
System.out.println("The class of Tree Map");
System.out.println(tm.getClass());
System.out.println("--------------------------------------");
System.out.println("The higher entry than the key 16 is");
System.out.println(tm.higherEntry(16));
System.out.println("--------------------------------------");
System.out.println("The lower entry than the key 16 is");
System.out.println(tm.lowerEntry(16));
System.out.println("--------------------------------------");
System.out.println("The first entry of given map");
System.out.println(tm.pollFirstEntry());
System.out.println("--------------------------------------");
System.out.println("The last entry of given map");
System.out.println(tm.pollLastEntry());
System.out.println("--------------------------------------");
System.out.println("The submap of given TreeMap from key 14 to key 20");
System.out.println(tm.subMap(14, 20));
System.out.println("--------------------------------------");
System.out.println(tm.subMap(14, false, 22, false));
System.out.println(tm.subMap(14, true, 22, true));
System.out.println(tm.subMap(14, true, 22, false));
System.out.println(tm.subMap(14, false, 22, true));
System.out.println("--------------------------------------");
System.out.println("The Key Set of our Mapping is");
System.out.println(tm.navigableKeySet());
System.out.println("--------------------------------------");
}
}

Google Script for Data Entry Form in Google Spreadsheet

// function to validate the entry made by user in user form function validateEntry (){ // declare a variable and referernece of active goog...