0

如何在 If 语句中比较两个 LongWritable ??? 喜欢,

if(compareTo(key1,new LongWritable(1))
 { 

    //do something;
 }
4

1 回答 1

2

LongWritable 实现 Comparable 所以使用 compareTo 方法:

if (lw1.compareTo(lw2) == 0) {
  // lw1 has same value as lw2
}
于 2013-04-22T14:40:17.403 回答