Solved

Null Boolean Values?

Posted on 2016-08-08
3
50 Views
Last Modified: 2016-08-09
intejiaIdea null defintionNull boolean values. Can someone simplify the explanation in the photo.

I understand that we can set Boolean values to false or true using mathematical calculations or string setting, but am confused as to when a Boolean would ever be "Null" or "NotNull".
0
Comment
Question by:rgb192
3 Comments
 
LVL 26

Accepted Solution

by:
dpearson earned 500 total points
ID: 41748173
In Java "bool" and "Boolean" are not quite equivalent.

"bool" is a primitive and only has 2 possible values - "true" or "false.
"Boolean" is an object and there can have 3 possible values - Boolean.TRUE, Boolean.FALSE or null.

e.g.
Boolean x = null ; // Legal
bool x = null ;  // Won't compile

That being said, this warning is actually saying that they've looked at your code and figured out that "m1 is always 3".

So B5 = (m1 != 3) ; will always be false (since m1 is always 3).  The null/non-null stuff isn't really coming into play in this instance - although it is good to understand them.

Hope that helps,

Doug
0
 
LVL 10

Expert Comment

by:HuaMinChen
ID: 41748193
A boolean can be defaulted to 'false'. In your case, it is true when m1 does not equal to 3.
0
 

Author Closing Comment

by:rgb192
ID: 41749578
true false null
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 18
eclipse shortcuts 9 45
how to add new optional parameter to JSP 1 26
servlet example issue 6 27
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now