How to use this boolean in an if statement?

前端 未结 8 1572
一个人的身影
一个人的身影 2020-11-28 15:35
private String getWhoozitYs(){
    StringBuffer sb = new StringBuffer();
    boolean stop = generator.nextBoolean();
    if(stop = true)
    {
        sb.append(\"y\         


        
8条回答
  •  感情败类
    2020-11-28 16:28

    The problem here is

    if (stop = true) is an assignation not a comparision.

    Try if (stop == true)

    Also take a look to the Top Ten Errors Java Programmers Make.

提交回复
热议问题