这听起来可能很愚蠢!但是,我想找到任何简单的例子来参考!有人可以举一个使用java打印混淆矩阵的例子吗?
像这样的东西(输出):
p\a Head Tail
Head 1 4
Tail 4 1
假设像这样存储在 HashMap 中的数据
HashMap<String,Integer>
String = "Head, Tail"
Integer = 4
更新(示例代码):
public static void main(String[] args) {
HashMap<String,Integer> cmatrix = new HashMap<String,Integer>();
//the string part can hold more the 2 values, all separated with comma
cmatrix.put("tail, head", 1);
cmatrix.put("head ,tail", 4);
cmatrix.put("tail, tail", 1);
cmatrix.put("head, head", 4);
for (Map.Entry entry : cmatrix.entrySet()) {
System.out.println(entry.getKey() +" : "+entry.getValue());
}
}
谢谢!