Else without if

you have an else statement after a for loop for(int i=3;i*i<=n;i+=2) { if(n%1==0) { System.out.println(“Your number isn’t prime.”); } } else { System.out.println(“Your number is prime!”); } you probably have to make a Boolean variable to do this one. there are various ways to do it, but here’s one that I would probably use boolean isPrime = true; for(int … Read more

Required: Variable Found: Value

You switched the operands in your assign statement. Switch this Math.abs(a[i]-a[i-1]) = biggestGap; to this biggestGap = Math.abs(a[i]-a[i-1]); Math.abs(a[i]-a[i-1]) returns just an int value (no variable reference or similar). So your trying to assign a new value to a value. Which is not possible. You can just assign a new value to a variable.

break statement in “if else” – java

Because your else isn’t attached to anything. The if without braces only encompasses the single statement that immediately follows it. if (choice==5) { System.out.println(“End of Game\n Thank you for playing with us!”); break; } else { System.out.println(“Not a valid choice!\n Please try again…\n”); } Not using braces is generally viewed as a bad practice because it can lead to … Read more