上でメソッドから情報を取得しますシンボル シンボル:メソッドnewhello() 場所:クラスHelloWorldのは、私はこれらは私が</p> <p>エラーを取得エラーですHelloWorld.java</p> <p>からnewhello.javaからRTNVALを呼び出すようにしようとしています別のファイル
エラー:(10、28)は、Java:シンボル シンボル見つけることができません:メソッドたnewval()を 場所:クラスHelloWorldの
public class HelloWorld {
public static void main (String[] args){
System.out.println("Test");
int fnum1 = addition(8,2);
System.out.println(fnum1);
int fnum2 = subtract(2,8);
System.out.println(fnum2);
newhello newval = newhello();
System.out.println(newval());
}
public static int addition (int num1, int num2){
int total;
total = num1 + num2;
return total;
}
public static int subtract (int num1, int num2){
int total;
total = num1 - num2;
return total;
}
}
public class newhello extends HelloWorld {
public static void main (String[] args){
System.out.println(rtnval());
}
public static String rtnval(){
String msg;
msg = "Test";
return msg;
}
}
私はそれを使用してインスタンスを呼び出さなければならないという印象を受けましたか?
あなたの解決策は修正プログラムでした。私はそれをNewHelloに正しく改名しました。私はそれをSystem.out.println(NewHello.rtnval())で問題なく呼び出すことができました。 質問。どのような状況で「非静的」なのだろうか? –