Im having trouble with my method return. I am new to using methods and cant seem to grasp the idea on the return part. I have to write a method that tells if a number is prime or not. This is what I have so far and it wont compile because it is saying "missing return statement } "... Please help!
import javax.swing.JOptionPane; public class IsPrimeMethod { public static void main(String []args) { String primeNum; int number; int i = 2; primeNum = JOptionPane.showInputDialog("Please enter a number: "); number = Integer.parseInt(primeNum); if(isPrime(number)) { JOptionPane.showMessageDialog(null, "Your number is not prime"); } else { JOptionPane.showMessageDialog(null, "Your number is prime"); } } public static boolean isPrime(int number) { for(int i = 2; i < number; i++) { if(number % i == 0) return true; else return false; } } }