2011-10-31 7 views
0
私は次のコードのエラーを取得してい

グアバのIterables.any()でコンパイル時エラー

Iterables.any(Lists.<String>newArrayList(), new Predicate<String>() { 
    @Override 
    public boolean apply(final String arg0) { 
    // TODO Auto-generated method stub 
    return false; 
    } 
}); 

エラー:

The method any(Iterable<T>, Predicate<? super T>) in the type Iterables is not applicable for the arguments (ArrayList<String>, new Predicate<String>(){})

私が間違っているのか?私は愚かな間違いをしているように感じる。

+3

あなたの輸入品はどのように見えますか? – Brigham

答えて

6

私は誤ったインポートを使用していました。

正しい

import com.google.common.base.Predicate; 
import com.google.common.collect.Iterables; 

誤:repackagedグアバを使用して

import com.google.appengine.repackaged.com.google.common.base.Predicate; 
import com.google.common.collect.Iterables; 

が問題となります。

+1

コンパイラのエラーメッセージがこのような場合に完全なパッケージ名(唯一)を示していれば、いいでしょう。 – Thilo

関連する問題