Solved

Null Boolean Values?

Posted on 2016-08-08
3
51 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
GUI builder for Eclipse? 8 37
by zero exception 10 41
Which non-HTML GUI front end to use with Java? 3 22
Glassfish admin console not working 1 16
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

832 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