Solved

Null Boolean Values?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

743 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

11 Experts available now in Live!

Get 1:1 Help Now