作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我偶然发现了一些关于大学作业的编译器错误。经过一段时间的尝试修复后,我真的没有找到纠正它们的解决方案。
以下是实现非确定性有限自动机的程序的构造函数。在这种情况下,我正在使用Hashsets和Hashmaps。
public NFA(Set<String> states, Set<String[]> transitions, String start, Set<String> end) {
this.start = start;
this.end = end;
this.active = this.start;
Map<String, String> x = new HashMap<String, String>(); //create placeholder map
//Insert states into map
for (String s: states) {
this.states.put(s, x); //Placeholder map used for this line
}
//Assign transitions to corresponding states.
for (String[] t: transitions) {
//this line throws the error.
if (!states.containsKey(t[0]) || !states.containsKey(t[2])) {
throw new IllegalArgumentException("Transition Data Corrupted!");
} else {
this.states.get(t[0]).put(t[1], t[2]);
}
}
}
result = new NFA(states, transitions, start, end);
NFA.java:27: error: cannot find symbol
if (!states.containsKey(t[0]) || !states.containsKey(t[2])) {
^
symbol: method containsKey(String)
location: variable states of type Set<String>
NFA.java:27: error: cannot find symbol
if (!states.containsKey(t[0]) || !states.containsKey(t[2])) {
^
symbol: method containsKey(String)
location: variable states of type Set<String>
The method containsKey(String) is undefined for the type Set<String>
最佳答案
您需要使用contains(String value)
进行设置。在Set<T>
中,没有键值关系。
关于java - 非确定性有限自动机(containsKey(string)不兼容的HashMap错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24355660/
为了了解 Redux 的动机,我阅读了官方链接 https://redux.js.org/introduction/motivation还有这个 stackoverflow 问题 Explain Re
您好,这个 firebase 函数曾经可以工作,但知道它现在工作时间更长了,我收到此错误消息 Function returned undefined, expected Promise or valu
我是一名优秀的程序员,十分优秀!