J
J
Jony13372016-05-23 20:46:27
Java
Jony1337, 2016-05-23 20:46:27

What is the problem in java code?

Hi everyone
, I'm learning java, from the lessons on youtube
he will see the code in the video, I decided to write it myself but it doesn't work

public class Hello {

   
    public static void main(String[] args) {
        Scanner scanner = new Scanner (System.in);
        int rezult = scanner.nextInt();
        if (rezult = 0) {
            System.out.println (this is  0);
        }
        else {
            System.out.println (is not 0);
        }
    }
    
}

what is the problem and how will it be correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanan Yuzb, 2016-05-23
@Jony1337

The comparison in the if block is wrong, it should be with two equals ==

if (rezult == 0) {
            System.out.println (this is  0);
        }
        else {
            System.out.println (is not 0);
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question