You need to break out of for loop as soon as you found if it is not a prime and slighlty modified approach you can follow to omit some code and optimize it as well.
public static boolean Isprime(int x){
boolean isprime = true;
for(int m=2;m<=Math.sqrt(x);m++){
int temp = x%m;
if(temp == 0){
isprime = false;
break;
}
}
return isprime;
}