java - .class expected error in my method and sometimes missing return statement error -


i new java , don't know why piece of code isn't compiling. isn't return result. suggestions?

public static char isprime(int x)         {              for(int y=2;y<x;y++)                 char result = 'r';                     if(x%y==0)                     result = 't';                     else                     result = 'f';              return result;         } 

or

public static char isprime(int x)         {             char result = 'r';             for(int y=2;y<x;y++)                      if(x%y==0)                     result = 't';                     else                     result = 'f';              return result;         } 

if use braces, code this:

public static char isprime(int x) {     for(int y=2;y<x;y++) {         char result = 'r';     }     if(x%y==0) {         result = 't';     }     else {         result = 'f';     }      return result; } 

as can see, variables y , result visible in loop


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -