Java版本
import java.util.HashMap;
import java.util.Map;
public class Main {
public static String KEY="TEST-KEY";
public static void main(String[] args) {
Map<String,Filed> map= new HashMap<>();
map.put(KEY,new Filed(100));
Filed v = map.get(KEY);
v.setCount(200);
System.out.println(map.get(KEY).getCount());
}
}
class Filed{
private int count;
public Filed(int count) {
this.count = count;
}
public void setCount(int count) {
this.count = count;
}
public int getCount() {
return count;
}
}
输出结果为: 200
Golang版本
package main
import "fmt"
const KEY = "TEST-KEY"
type Filed struct {
Count int
}