一个小问题,这个warning的怎么解决?

alcla 2005-10-24 09:04:07
javac -Xlint *.java
waring:[unchecked] unchecked conversion
found PQcomparator
require:java.utill.Comparator<? super node>
bestSucc = new PriorityQueue<node>(1,new PQComparator());
1 warning

my PQComparator class is:
import java.util.Comparator;
class PQComparator implements Comparator{
node t1;
node t2;
public int compare(Object a,Object b){
t1= (node)a;
t2= (node)b;
return t1.getNum()-t2.getNum();
}
}
...全文
373 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
yy80680169 2005-11-05
  • 打赏
  • 举报
回复
UP
believefym 2005-10-27
  • 打赏
  • 举报
回复
Comparator的泛型警告还是不解
zhouyong80 2005-10-27
  • 打赏
  • 举报
回复
这是个泛型的问题.泛型是J2SE 5.0最重要的特性。关于这个在我的Blog里有详细的介绍,建议你去看一下就全明白了.地址是:http://blog.csdn.net/zhouyong80/archive/2005/10/26/517076.aspx
紫炎圣骑 2005-10-26
  • 打赏
  • 举报
回复
up
lyj830223 2005-10-25
  • 打赏
  • 举报
回复
学习中……
Mark_Chen 2005-10-25
  • 打赏
  • 举报
回复
up!!
believefym 2005-10-24
  • 打赏
  • 举报
回复
跟楼主共同关注
alcla 2005-10-24
  • 打赏
  • 举报
回复
just in my code like following:
public class test{
Random rand;
int nVars; //the number of propositional variables
int nCals; //the number of clauses
int[] symbolPool; //all the variables strore in this array
int[] caluse = new int[3];
ArrayList<int[]> formula;
ArrayList<node> nodeList;
int max_restarts;
int max_climbs;
private PriorityQueue<node> bestSucc;
private PriorityQueue<node> bestSuccTemp;

test(){
bestSucc = new PriorityQueue<node>(1,new PQComparator());
formula = new ArrayList<int[]>();
nodeList = new ArrayList<node>();
rand = new Random();
nVars = 100;
nCals = 100;
max_restarts = 100;
max_climbs = 500;
}
....................
with the line new PriorityQueue<node>(1,new PQComparator());
alcla 2005-10-24
  • 打赏
  • 举报
回复
up
trumplet 2005-10-24
  • 打赏
  • 举报
回复
我用netBeans 5.0 beta,单独编译PQComparator没有出现警告。

不知道bestSucc = new PriorityQueue<node>(1,new PQComparator());是哪个类的,是否与调用有关呢。
alcla 2005-10-24
  • 打赏
  • 举报
回复
another simple question is:
int[] caluse = new int[3];
ArrayList<int[]> formula = new ArrayList<int[]>();
formula.add(caluse);
but the formula ArrayList only check the item add into it is a int[] while i want to give a restrict add with every item must be int[3];
like ArrayList<int[3]> formula = new ArrayList<int[]>();
but it does not work;
instead create a class like caluseNode{
int a = new int[3];
}
and do the following declare:
ArrayList<caluseNode> formula = new ArrayList<int[]>();
is there any other solutions?
believefym 2005-10-24
  • 打赏
  • 举报
回复
我也一直在考虑这个问题,gg也搜不到,这个是个泛型的警告
alcla 2005-10-24
  • 打赏
  • 举报
回复
up

62,625

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧