別のランナープログラムで呼び出された.datファイルからグレード値と名前の値を取り込もうとしています。この他のjavaファイル内のクラスは、私たちのために始めた、と私たちは、私は、エラー互換性のない型int []はint型のエラーに変換できません
Incompatible types: int[] cannot be converted to int" error for "grades[i]=g;" and the corresponding String error for "names[i]=n;
に取得しています「... forループを使用する」
を「...両方の配列をインスタンス化」としていました
思考?
public GradeBook(int[] g, String[] n, int num)
{
// **instantiate both arrays with 'num' objects
String []names=new String[num];
int[] grades=new int[num];
//**use a for-loop to assign each name and grade with the incoming values
for(int i=0;i<num;i++)
{
names[i]=n;
grades[i]=g;
}
}
クラスの完全なコードを含めてください。私はここでは反復のポイントが全く見当たらないので、入ってくる配列を割り当てて、それを使って終了してください。 –
あなたは 'names [i] = n [i]; grades [i] = g [i];ただし、https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#copyOf(int[],%20int)はより良い –
@TimBiegeleisen 'num'は' n.length'とは異なる値になるかもしれません。 –