java - Trouble with method taking the correct type -


so, i'm new java (just started class last week), , i'm trying write class manipulate prime numbers. i'm pretty python, have no idea i'm doing here apparently. when try use isprime method error:

"cannot invoke isprime() on primitive type int."

any help? near can tell, method should take int , assign method variable p. have backwards? help!

public class prime {      private int prime;      public static void main(string[] args) {         int seventeen = 17;         int 5 = 5;         int twentyfour = 24;         system.out.println(twentyfour.isprime());         system.out.println(seventeen.isprime());         system.out.println(five.isprime());     }      public prime(int p) {         prime = p;     }      public boolean isprime(int p){         int i=0;         if(p==1 || p==0)             return false;         for(i=2; i<=p; i++) {             if(p%i == 0)                 return false;         }         return true;     }      public int getprime(){         prime++;         while(!prime.isprime()){             prime++;         }         return prime;            }      public void reset(){         prime = 1;     } } 

you call this:

new prime().isprime(26); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -