Solved

Null Boolean Values?

Posted on 2016-08-08
3
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

617 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