gpt4 book ai didi

java - 实现深度优先搜索: incompatible objects

转载 作者:行者123 更新时间:2023-11-30 04:25:59 31 4
gpt4 key购买 nike

我正在尝试实现一个呼吸优先的搜索,用于搜索罗马尼亚城市的人工智能程序。

但是,我在这方面遇到了很多麻烦,最新的错误是

searches.java:153: error: incompatible types
current = q.poll();
^
required: city
found: Object
Note: searches.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

最佳答案

您需要声明队列的类型:

Queue<City> q = new LinkedList<City>();     

我已将您的 city 更改为 City,因为您的类名应始终以大写字母 as shown in this document 开头.

关于java - 实现深度优先搜索: incompatible objects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15865794/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com