If statement always giving the same answer

前端 未结 7 522
-上瘾入骨i
-上瘾入骨i 2020-12-12 03:26
import java.util.Scanner;

class Practice {

public static void main(String args[]) {

    System.out.println(\"Enter the number of treats you have:\");
    Scanner          


        
7条回答
  •  庸人自扰
    2020-12-12 04:01

    You are assigning the value true to enoughtreats.

    Try using the equality operator rather than assignment:

    if (enoughtreats == true) {
    ...
    }
    

    or simply:

    if(enoughtreats) {
    ...
    }
    

提交回复
热议问题