What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example - Hallo sahabat BEST LEARNING JAVA, Pada Artikel yang anda baca kali ini dengan judul What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan
Artikel core java,
Artikel core java interview question,
Artikel java collection tutorial,
Artikel programming, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.
Judul : What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
link : What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
Further Learning
Java In-Depth: Become a Complete Java Engineer
How to form HashMap inwards Java past times keys together with values
Judul : What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
link : What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
NavigableMap inwards Java vi is an extension of SortedMap like TreeMap which provides convenient navigation method similar lowerKey, floorKey, ceilingKey together with higherKey. NavigableMap is added on Java 1.6 together with along amongst these pop navigation method it every bit good render ways to create a Sub Map from existing Map inwards Java e.g. headMap whose keys are less than specified key, tailMap whose keys are greater than specified cardinal together with a subMap which is strictly contains keys which falls betwixt toKey together with fromKey. All of these methods every bit good provides a boolean to include specified cardinal or not. TreeMap together with ConcurrentSkipListMap are 2 concrete implementation of NavigableMap inwards Java 1.6 API. Though NavigableMap is non every bit pop every bit HashMap, ConcurrentHashMap or Hashtable only given that TreeMap implements NavigableMap yous already teach all expert things inwards a good known Map implementation.
How to work NavigableMap inwards Java - Example
In this Java tutorial nosotros volition explore roughly API methods of NavigableMap to demo its functionality. This Java plan shows event of lowerKey which returns keys less than specified, floorKey returns cardinal less than or equal to, ceilingKey render greater than or equal to together with higherKey which returns keys which are greater than specified key.
This Java event every bit good demonstrate work of headMap(), tailMap() together with subMap() method which is used to practise Map from an existing Map inwards Java. headMap returns a Map whose keys are lower than specified keys piece tailMap returns Map which contains keys, those are higher than specified. Here is consummate code event of How to work NavigableMap inwards Java.
This Java event every bit good demonstrate work of headMap(), tailMap() together with subMap() method which is used to practise Map from an existing Map inwards Java. headMap returns a Map whose keys are lower than specified keys piece tailMap returns Map which contains keys, those are higher than specified. Here is consummate code event of How to work NavigableMap inwards Java.
import java.util.NavigableMap;
import java.util.TreeMap;
/**
*
* Java plan to demonstrate What is NavigableMap inwards Java together with How to work NavigableMap
import java.util.TreeMap;
/**
*
* Java plan to demonstrate What is NavigableMap inwards Java together with How to work NavigableMap
* inwards Java. NavigableMap provides 2 of import features navigation methods
* similar lowerKey(), floorKey, ceilingKey() together with higherKey().
* There Entry counterpart together with methods to practise subMap e.g. headMap(), tailMap()
* There Entry counterpart together with methods to practise subMap e.g. headMap(), tailMap()
* together with subMap().
*
* @author Javin Paul
*/
public class NavigableMapExample {
public static void main(String args[]) {
//NavigableMap extends SortedMap to render useful navigation methods
NavigableMap<String, String> navigableMap = new TreeMap<String, String>();
navigableMap.put("C++", "Good programming language");
navigableMap.put("Java", "Another expert programming language");
navigableMap.put("Scala", "Another JVM language");
navigableMap.put("Python", "Language which Google use");
System.out.println("SorteMap : " + navigableMap);
//lowerKey returns cardinal which is less than specified key
System.out.println("lowerKey from Java : " + navigableMap.lowerKey("Java"));
//floorKey returns cardinal which is less than or equal to specified key
System.out.println("floorKey from Java: " + navigableMap.floorKey("Java"));
//ceilingKey returns cardinal which is greater than or equal to specified key
System.out.println("ceilingKey from Java: " + navigableMap.ceilingKey("Java"));
//higherKey returns cardinal which is greater specified key
System.out.println("higherKey from Java: " + navigableMap.higherKey("Java"));
//Apart from navigagtion methodk, it every bit good provides useful method
//to practise subMap from existing Map e.g. tailMap, headMap together with subMap
//an event of headMap - returns NavigableMap whose cardinal is less than specified
NavigableMap<String, String> headMap = navigableMap.headMap("Python", false);
System.out.println("headMap created shape navigableMap : " + headMap);
//an event of tailMap - returns NavigableMap whose cardinal is greater than specified
NavigableMap<String, String> tailMap = navigableMap.tailMap("Scala", false);
System.out.println("tailMap created shape navigableMap : " + tailMap);
//an event of subMap - render NavigableMap from toKey to fromKey
NavigableMap<String, String> subMap = navigableMap.subMap("C++", false ,
*
* @author Javin Paul
*/
public class NavigableMapExample {
public static void main(String args[]) {
//NavigableMap extends SortedMap to render useful navigation methods
NavigableMap<String, String> navigableMap = new TreeMap<String, String>();
navigableMap.put("C++", "Good programming language");
navigableMap.put("Java", "Another expert programming language");
navigableMap.put("Scala", "Another JVM language");
navigableMap.put("Python", "Language which Google use");
System.out.println("SorteMap : " + navigableMap);
//lowerKey returns cardinal which is less than specified key
System.out.println("lowerKey from Java : " + navigableMap.lowerKey("Java"));
//floorKey returns cardinal which is less than or equal to specified key
System.out.println("floorKey from Java: " + navigableMap.floorKey("Java"));
//ceilingKey returns cardinal which is greater than or equal to specified key
System.out.println("ceilingKey from Java: " + navigableMap.ceilingKey("Java"));
//higherKey returns cardinal which is greater specified key
System.out.println("higherKey from Java: " + navigableMap.higherKey("Java"));
//Apart from navigagtion methodk, it every bit good provides useful method
//to practise subMap from existing Map e.g. tailMap, headMap together with subMap
//an event of headMap - returns NavigableMap whose cardinal is less than specified
NavigableMap<String, String> headMap = navigableMap.headMap("Python", false);
System.out.println("headMap created shape navigableMap : " + headMap);
//an event of tailMap - returns NavigableMap whose cardinal is greater than specified
NavigableMap<String, String> tailMap = navigableMap.tailMap("Scala", false);
System.out.println("tailMap created shape navigableMap : " + tailMap);
//an event of subMap - render NavigableMap from toKey to fromKey
NavigableMap<String, String> subMap = navigableMap.subMap("C++", false ,
"Python", false);
System.out.println("subMap created shape navigableMap : " + subMap);
}
}
Output:
SorteMap : {C++=Good programming language, Java=Another expert programming language, Python=Language which Google use, Scala=Another JVM language}
lowerKey from Java : C++
floorKey from Java: Java
ceilingKey from Java: Java
higherKey from Java: Python
headMap created shape navigableMap : {C++=Good programming language, Java=Another expert programming language}
tailMap created shape navigableMap : {}
subMap created shape navigableMap : {Java=Another expert programming language}
System.out.println("subMap created shape navigableMap : " + subMap);
}
}
Output:
SorteMap : {C++=Good programming language, Java=Another expert programming language, Python=Language which Google use, Scala=Another JVM language}
lowerKey from Java : C++
floorKey from Java: Java
ceilingKey from Java: Java
higherKey from Java: Python
headMap created shape navigableMap : {C++=Good programming language, Java=Another expert programming language}
tailMap created shape navigableMap : {}
subMap created shape navigableMap : {Java=Another expert programming language}
That's all on What is NavigableMap inwards Java together with How to work NavigableMap amongst example. We accept seen examples of pop navigation method on TreeMap e.g. floorKey. You tin every bit good work similar method similar lowerEntry, floorEntry, ceilingEntry together with higherEntry to yell upwardly Entry instead of key. NavigableMap is every bit good a expert utility to practise subset of a Map inwards Java.
Further Learning
Java In-Depth: Become a Complete Java Engineer
How to form HashMap inwards Java past times keys together with values
Demikianlah Artikel What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example
Sekianlah artikel What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
Anda sekarang membaca artikel What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example dengan alamat link https://bestlearningjava.blogspot.com/2017/06/what-is-navigablemap-inwards-coffee-vi.html
Belum ada Komentar untuk "What Is Navigablemap Inwards Coffee Vi - Creating Submap From Map Amongst Example"
Posting Komentar