java - I do not understand this error 'Syntax error on token ";", { expected after this token' -
currently have error syntax error on token ";", { expected after token
, in code shown below:
public class findkey { private final static arraylist<integer> listofprimes = new arraylist<>(); //number of primes want private final static int n = 224; (int candidate = 2, count = 0; count < n; ++candidate) { if (isprime(candidate)) { ++count; listofprimes.add(candidate); } } // simple isprime() function // miller-rabin algorithm added reference private static boolean isprime(int num) { if (num == 2 ) { return true; } if (num % 2 == 0) { return false; } (int = 3; * <= num; += 2) { if (num % == 0) return false; } return true; } public static int convertkey (string input) { int result; char[] chararray = input.tochararray(); (int = 0; < chararray.length; i++){ result *= listofprimes.get(convertint(chararray[i])); } return result; } private static int convertint (char a) { int ascii = (int)a; int = ascii - 32; return i; } }
i not understand error is. sure stupid blanking over. appreciated problem.
any details answered if asked.
it appears based on comment
can loops not exist outside method in class? started programming in java after c
that expect behavior of static
initializing block. like,
static { (int candidate = 2, count = 0; count < n; ++candidate) { if (isprime(candidate)) { ++count; listofprimes.add(candidate); } } }
Comments
Post a Comment