返回此地图中的键值映射的数量。
句法
- int size()
参数
没有。
返回值
地图的大小。
例子
下面是一个使用这个方法的例子 -
- class Example {
- static void main(String[] args) {
- def mp = ["TopicName" : "Maps", "TopicDescription" : "Methods in Maps"]
- println(mp.size());
- mp.put("TopicID","1");
- println(mp.size());
- }
- }
当我们运行上面的程序,我们将得到以下结果 -
- 2
- 3
转载本站内容时,请务必注明来自W3xue,违者必究。