私の質問は、JAVA の基礎を扱っています。Android アプリを作成しており、メソッド内で作成した匿名スレッド内のメソッド パラメーターにアクセスしたいと考えています。どういうわけか、ヌルポインタ例外が発生し続けます。私のコードは次のようになります。
public void myMethod(final float x, final float y){
new Thread(new Runnable(){
float xx = x;
float yy = y;
@Override
public void run(){
//inside run method I create a for loop that uses the "x" and "y" parameters
//as "xx" and "yy", respectively.
//keep getting null pointer exception on line where i attempt to do
//calculations with x and y
}
}).start();
}
誰かが答えてくれれば、それは素晴らしいことです。メソッドを静的にする必要がありますか? おそらく、最後のキーワードを取り除きますか?
ありがとうございました