freemarker怎么获取map的key

freemarker怎么获取map的key,第1张

<#assign keys = mapkeys>

<#list Keys as key>

key:${key}

</#list>

sortedList<int, string>

这是一个键值对集合

Keys就是这个集合的键 也就是你添加时候的第一个参数

listadd(2,"str2"); 这个的key就是2

listKeys 就是你添加的2,1,3

List指的是集合<>是泛型,里面指定了这个集合中存放的是什么数据

比如有一个学生类Student,Student里面包含了学生的一些信息这样每一个Student对象就代表了一个学生此时List<Student>就代表这个集合中存放了很多个学生对象,这个集合就像一个班级一样

看例子

import javautilArrayList;

import javautilCollections;

import javautilComparator;

import javautilList;

import javautilScanner;

public class Test {

public static void main(String[] args) {

List<Record> list = new ArrayList<Record>();

Collectionssort(list, new Comparator<Record>(){

public int compare(Record o1, Record o2) {

if(o1getKey1() > o2getKey1()){

return 1;

}else if(o1getKey1() == o2getKey1()){

if(o1getKey2() > o2getKey2()){

return 1;

}else if(o1getKey2() == o2getKey2()){

//TODO: compare key3

return -1;

}else{

return 0;

}

}else{

return 0;

}

}

});

}

}

class Record{

private int key1, key2, key3;

public int getKey1() {

return key1;

}

public int getKey2() {

return key2;

}

public int getKey3() {

return key3;

}

}

以上就是关于freemarker怎么获取map的key全部的内容,包括:freemarker怎么获取map的key、C#中的.keys是什么东西求大神看下这段代码!!!、JAVA里的List<Type>& keys中&什么意思等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/10135138.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存