//Checks if the guess matches the random number
if (g1 == Random) {
//System print line statement to tell the user that their guess was the same as the random number
System.out.println("Correct");
//System print line statement to display number of guesses and the word 'guesses'
System.out.println(counter + " Guesses");
}
//If the guess is lower than the random number the console will print 'Wrong, try higher'
else if (Random > g1) {
System.out.println("Wrong, try higher");
}
//If the guess higher than the random number the console will display 'Wrong, try lower'
else {
System.out.println("Wrong, try lower");
}
if(a && b) // And operator
if(a || b) // Or operator
class IfStatement {
public static void main(String[] args) {
int number = 10;
// checks if number is less than 0
if (number < 0) {
System.out.println("The number is negative.");
}
System.out.println("Statement outside if block");
}
}
int hi = 30
if (hi < 5) {
System.out.println("ok");
}
else {
System.out.println("no");
}
if (str != null && !str.isEmpty()) {
doSomethingWith(str.charAt(0));
}
int num = 5;
if (n > 0) {
System.out.println("This is a positive number")
}