import java.utils.Scanner;
public class PD {
public static void main(String[] args) {
System.out.print("Enter your number: " );
int number = input.nextInt();
System.out.println( DPPP(number) + "is double palidromic prime");
}
// main method checks every other method and returns a value that follows everything
public static int DPPP( int number) {
int count = 2;
while (count < number) {
String blank = "";
String Snumber = count + blank;
if (isPalindromic(count) && isPrime(count) &&
isPalindromic(Snumber.length()) && isPrime(Snumber.length()))
return count;
count++;
}
}
// method to find palindromic
public static boolean isPalindromic(int number) {
String blank = "";
String convert = count + blank;
for (int i = 0, int q = 1; i <= (convert.length()/2 - 1); i++, q++) {
if (convert.substring(i,q) == number.substring(number.length() - q, number.length() - i))
return true;
else
return false;
}
}
// method to find prime
public static boolean isPrime(int number) {
for (int divisor = 2; divisor <= number/2; divisor++) {
if (number % divisor == 0) {
return false;
}
}
return true;
}
}
错误:
PD.java:28: <identifier> expected
for (int i = 0, int q = 1; i <= (convert.length()/2 - 1); i++, q++) {
^
PD.java:28: not a statement
for (int i = 0, int q = 1; i <= (convert.length()/2 - 1); i++, q++) {
^
PD.java:28: ')' expected
for (int i = 0, int q = 1; i <= (convert.length()/2 - 1); i++, q++) {
^
PD.java:28: ';' expected
for (int i = 0, int q = 1; i <= (convert.length()/2 - 1); i++, q++) {
^
PD.java:28: ';' expected
for (int i = 0, int q = 1; i <= (convert.length()/2 - 1); i++, q++) {
而且我不确定为什么它要求放置一个 ; 以及为什么它说这不是一个声明
总的来说,我得到了那个错误,我不明白为什么。感谢您的帮助!我知道我的程序可能不正确,但我真的想专注于修复这个错误。再次感谢您的帮助和时间。