Doubt on how to use "!="

Asked

Viewed 55 times

0

Sometimes I come across the exclamation mark ! before the equal character =and I always have a question of why I have it there. Small example:

if (model.getFile() != null){

I know that if the result of model.getFile() for true follows the code, but what ! explicitly does?

  • 1

    denial: Read more se(model.getFile() é diferente de null))

  • then if you have , = read se(model.getFile() é igual null))

  • Access one of the links marked as duplicate, it has a more detailed explanation.

  • 3

    No, the opposite of != is ==.

  • so now I understand... and if you have only = ?

  • Ai is attribution and not comparison.

  • Wallace, the exclamation mark basically reverses the value of the condition, for example: !true will be verified if it is false, and along with the symbol of equal logic is the same: == (is equal), != (is different)

  • interesting entedi , I tried to search before I didn’t know how to ask google :) ,Thanks.

  • @Jefferson Quesado , my dumb say that ! was interrogation , Thanks for the correction.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.