これは私が正しいことをしていないかどうか教えてください。これはStackOverflowに関する私の最初の質問です。とにかく、私はかなり徹底的に調査しましたが、私の問題に対する答えを見つけることができないようです。私がアクセスしたいメソッドは、Java(Jgrasp)ではアクセスされません。なぜ私は右の表記を使用しているように感じるので、私はなぜわからない。Java:メソッドにアクセスできない
//PROJECT EULER Problem #4
//A palindromic number reads the same both ways. The largest palindrome made
//from the product of two 2-digit numbers is 9009 = 91 × 99.
//Find the largest palindrome made from the product of two 3-digit numbers.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class PE4
{
public boolean isPalindrome(int five)
{
String word = Integer.toString(five);
if (word.length()==5 &&word.substring(0,2).equals(word.substring(3,5)))
return true;
else if(word.length()==6 &&word.substring(0,3).equals(word.substring(3,6)))
return true;
else
return false;
}
public static void NumberFinder()
{
for (int i=999; i>599; i--)
{
for (int j=999; j>i-300; j--)
{
if (isPalindrome(i*j)==true)
{
System.out.print(i + ", " + j + " = " + i*j);
break outerloop;
}
}
}
return 0;
}
PE4 tester = new PE4();
tester.NumberFinder();
}
私の質問を読んでいただきありがとうございます。
アンナ
このコードはコンパイルされますか?私の推測はノーです。その場合は、コンパイルエラーを投稿してください。 –
'main'メソッドは必要ありませんか? –
非静的メソッド 'isPalindrome'が静的メソッドから呼び出されています。推奨される読解[クラスメンバーの理解](https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html) – copeg