0
私はJavaのCombinationsクラスのインポートステートメントを教えてもらえますか?
import java.lang.org.apache.commons.math3.util.Combinations;
によって組み合わせをインポートしようとしましたが、私は私のソースコードでの組み合わせを使用するときにエラーを取得しておきます。
import java.util.*;
import java.org.apache.commons.math3.util.Combinations;
public class PowerSet{ //gets power set for a set containing first n integers
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(args[0]);
for(int i=0; i<=n; i++){
Combinations c = new Combinations(n,i);
Iterator iter = c.iterator();
while(iter.hasNext()){
int[] iarr = (int[])iter.next();
System.out.print("{" + iarr[0]);
for(int a=1; a<iarr.length; a++){
System.out.println(", " + iarr[a]);
}
System.out.print("}, ");
}
}
}
}
エラーが表示され、クラスが存在しないことが明らかです。階層が間違っていたり、クラスをインポートした方が間違っていますか?あなたはimport文
java.lang.org.apache.commons.math3.util.Combinations;
から見ることができるように
package java.org.apache.commons.math3.util does not exist
import java.org.apache.commons.math3.util.Combinations;
^
PowerSet.java:11: error: cannot find symbol
Combinations c = new Combinations(n,i);
^
symbol: class Combinations
location: class PowerSet
あなたのプロジェクトにパッケージを追加しましたか( 'Combinations'はJavaクラスではありませんが、Apache Projectライブラリから追加されました)?どのIDEを使用していますか? – AntonH
パッケージの先頭には 'java.'がありません。あなたはあなたのIDEにインポートを残す必要があります。 – bcsb1001
'java.lang'ビットを省略します。 –