| | |
Boolean class
![]() |
•
•
Join Date: Apr 2009
Posts: 114
Reputation:
Solved Threads: 3
0
#2 18 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: 972
Reputation:
Solved Threads: 146
0
#3 18 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 18 Days Ago
Last edited by KirkPatrick; 18 Days Ago at 2:11 pm.
0
#6 18 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; 18 Days Ago at 5:00 pm.
0
#7 17 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? [ Solved by : niek_e ]
2) What does this sequence equal to : (.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 |
6 actuate android api applet application applications array arrays automation balls bank binary bluetooth bold business c++ chat class clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse educational error file formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide ideas image infinite ingres integer intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans openjavafx parameter php problem program programming project recursion repositories scanner scrollbar sell server set sms sort sorting sql sqlserver state storm string sun superclass swing swt threads tree websites windows







