public class SecureSystem {
final int low = 0;
final int high = 1;
HashMap<String, int[]> subject;
HashMap<String, int[]> object;
public SecureSystem() {
subject = new HashMap<String, int[]>();
object = new HashMap<String, int[]>();
}
ReferenceMonitor rm = new ReferenceMonitor();
rm.ReferenceMonitor(subject,object);
System.out.println(this.subject.get("a")); // how to make it print [1,2]?
System.out.println(this.object.get("b")); // how to make it print [3,4]?
}
class ReferenceMonitor{
ReferenceMonior(HashMap<String, int[]> subject, HashMap<String, int[]> object) {
SecureSystem ss = new SecureSystem();
ss.subject.put("a", new int{1,2});
ss.object.put("a", new int{3,4})
}
}
我怎样才能做到这一点?如果我将 HashMaps 传递给 ReferenceMonitor 类,并尝试读取内容,我会得到 NullPointerError。
太感谢了。