30 lines
1007 B
Java
Raw Normal View History

2016-08-02 11:52:46 -06:00
// understandingcollections/FillMapTest.java
2016-07-05 14:46:09 -06:00
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
2016-07-05 14:46:09 -06:00
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import onjava.*;
public class FillMapTest {
public static void main(String[] args) {
Map<String,Integer> mcs = FillMap.basic(
new Rand.String(4), new Count.Integer(), 7);
System.out.println(mcs);
HashMap<String,Integer> hashm = FillMap.create(
new Rand.String(4), new Count.Integer(),
HashMap::new, 7);
System.out.println(hashm);
LinkedHashMap<String,Integer> linkm = FillMap.create(
new Rand.String(4), new Count.Integer(),
LinkedHashMap::new, 7);
System.out.println(linkm);
}
}
/* Output:
{npcc=1, ztdv=6, gvgm=3, btpe=0, einn=4, eelo=5, uxsz=2}
{npcc=1, ztdv=6, gvgm=3, btpe=0, einn=4, eelo=5, uxsz=2}
{btpe=0, npcc=1, uxsz=2, gvgm=3, einn=4, eelo=5, ztdv=6}
*/