私はインターネットを閲覧していましたが、解決策を見つけることができませんでした。 (size.add(QSIZE);)私はまだEclipseは私が指定して、私の.add ArrayListに反対する必要があることを私に言っていArrayListのJavaエラー
import java.util.ArrayList;
public class Memoire{
int taille; //Size of the memory in bits
boolean flag = true; //At "0" if the memory is fully utelized. Else at "1"
ArrayList pid = new ArrayList(); //Use to store the pid
ArrayList size = new ArrayList(); //Use to store the amount of memory allocated for each pid
public void memoire()
{
}
public void memoire(int qTaille)
{
taille = qTaille;
}
public boolean allouer(int qSize, int qPid,boolean force)//The Process ID (pid) bind the allocated memory to his process
{
int left = verifMemoire(qSize); //Get the remaining memory
if(left < qSize) //If the remaning memory is larger than the request
{
pid.add(qPid); //Store the pid
size.add(qSize); //Store the size
}
else
{
if(force) //If the user want to force the allocation
{
pid.add(qPid); //Store the pid
size.add(left); //Sotre the remaining memory size
}
else
{
return false; //If the user don't want to force, return an error
}
}
return true; //Return the success of the allocation
}
:
は、ここに私のコードです。本当に必要ですか?
これはコンプライアンスエラーだけではありません。リストが宣言される方法です
*** verifMemoire(qSize)***を教えてくれるまで、私はエラーを再現しません。 *** verifMemoire(qSize)***が定義されていますか? –
実際のエラーメッセージとは何ですか?あなたのコード(とエラー)を単純化するためにジェネリックを使うことをお勧めします。 –
確かに型を指定せずに 'ArrayList'を使い、' int'を追加しようとします。私はそれが "オブジェクト"を取得するために2つの "キャスト"この必要性を動作するとは思わない – AxelH