Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Null Boolean Values?

Posted on 2016-08-08
3
Medium Priority
?
59 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 28

Accepted Solution

by:
dpearson earned 2000 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 11

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

972 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