| | |
Boolean class
![]() |
•
•
Join Date: Apr 2009
Posts: 114
Reputation:
Solved Threads: 3
0
#2 16 Days Ago
•
•
•
•
Public final static Boolean FALSE=new Boolean(false);
Public final static Boolean TRUE=new Boolean(true);
what is the meaning of above two statements?
I'm also not quite sure why someone would want to create a true/false when the point of a boolean is to determine whether it is true or false.
For example:
java Syntax (Toggle Plain Text)
private boolean isWindows; if (isWindows == true) // do something only a windows os can do else // do something only a unix os can do
Obviously there are more operating system's than those two but that shows how a boolean would work. Or at least how I use my booleans instead of creating true false
•
•
Join Date: Apr 2008
Posts: 971
Reputation:
Solved Threads: 146
0
#3 16 Days Ago
These two statements create two constants TRUE and FALSE (Java constants are captialised by convention). These constants are members of the Boolean class, with values true and false respectively.
Back in the old days befor Java 1.5 the compiler would not convert automatically between Boolean (the class) members and boolean (primitive) values, so it was useful to have constants for the class members. Now Java will autobox true and false into Boolean class members automatically this is no longer of any great use.
ps sridhar123:
is a dumb way of saying
Back in the old days befor Java 1.5 the compiler would not convert automatically between Boolean (the class) members and boolean (primitive) values, so it was useful to have constants for the class members. Now Java will autobox true and false into Boolean class members automatically this is no longer of any great use.
ps sridhar123:
if (isWindows == true) is a dumb way of saying
if (isWindows) •
•
Join Date: Apr 2009
Posts: 114
Reputation:
Solved Threads: 3
0
#4 16 Days Ago
Last edited by KirkPatrick; 16 Days Ago at 2:11 pm.
0
#6 16 Days Ago
++
Me too. Not only is it unnecessary, the code just reads a whole lot cleaner without them.
Me too. Not only is it unnecessary, the code just reads a whole lot cleaner without them.
Java Syntax (Toggle Plain Text)
if (isComplete) {...
Last edited by Ezzaral; 16 Days Ago at 5:00 pm.
0
#7 15 Days Ago
•
•
•
•
++
Me too. Not only is it unnecessary, the code just reads a whole lot cleaner without them.Java Syntax (Toggle Plain Text)
if (isComplete) {...
name. When giving a variable name, if giving it isBlah doesn't
necessarily make sense, for example, suppose you have a state flag
the in that case I would rather do this :
Java Syntax (Toggle Plain Text)
if(state == false)
Java Syntax (Toggle Plain Text)
if(!state)
I am not sure which one would be faster, but I guess it depends on
many things, but I assume it would be the same in a decent
compiler.
I give up! 1) What word becomes shorter if you add a letter to it? 2) What does this equal : (.5u - .5a)(.5u-.5b)(.5u-.5c) ... 3) What is the 123456789 prime numer?
![]() |
Similar Threads
- JDBC not recognizing ResultSet assingment (?) (Java)
- Explain toString() and constructors, and their use? (Java)
- urgently need help (Java)
- cannot explain the arrayIndexOutofBoundsException (Java)
- HELP!!! I cant figure this out!! (Java)
- JTable Reloading/Refreshing/Updating/Whatever. (Java)
- Class & method Boolean (Java)
- I need help in C++ (C++)
Other Threads in the Java Forum
- Previous Thread: Algorithm for creating a linked list that is sorted as nodes are inserted
- Next Thread: Need Project Suggestion
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows







