Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2007, 09:56 AM
Senior Member
 
Join Date: Nov 2007
Posts: 115
ravian is on a distinguished road
boolean variables
I am confused about boolean variables. What is the use of boolean variables? We can use short variable (as a flag) for the required purpose then what edge does boolean variables gives us?

Code:
if(var == 1) System.out.println("true"); else System.out.println("false");
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-13-2007, 10:54 AM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
Code:
var == 1
Right now you are using a boolean operator (the double = sign). The result of the following equation is true of false. '
The use is this (in pseudocode):
Code:
boolean isAuthenticated = false; if (passWordIsCorrect) isAuthenticated = true; else isAuthenticated = false; if (isAuthenticated) allowToSeeSecretData;
note: Pseudo code is English, written in a more code like form, just to make sense. That of course will not compile.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-13-2007, 03:28 PM
Senior Member
 
Join Date: Nov 2007
Posts: 115
ravian is on a distinguished road
So its slower in that case. If I use boolean variable, it will be faster... Is this what you mean?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-31-2007, 05:58 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 839
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Quote:
Originally Posted by ravian View Post
So its slower in that case. If I use boolean variable, it will be faster... Is this what you mean?
It's more of a convenience to further abstraction, fundamental to OOP.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing boolean Values of another values in one class. a_iyer20 Advanced Java 4 04-15-2008 02:04 PM
boolean to string otoro_java New To Java 2 01-30-2008 06:31 AM
Variables mew New To Java 3 12-11-2007 01:44 PM
Error: incompatible types, found: int required: boolean silvia New To Java 1 07-19-2007 08:33 PM
Boolean Expression ritwik07 New To Java 3 07-11-2007 05:11 AM


All times are GMT +3. The time now is 05:36 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org