Results 1 to 9 of 9
  1. #1
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

    Default Boolean Data type

    Hi guys,

    Is there Boolean data type other then boolean data type? Cause when i tried declaring a variable like Boolean b and tried assigning a value to it like Boolean b =true; it threw an error saying incompatible types.


    Thank you.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

    Default

    Quote Originally Posted by maya700 View Post
    Is there Boolean data type other then boolean data type?
    Take a look in the API.

    Quote Originally Posted by maya700 View Post
    when i tried declaring a variable like Boolean b and tried assigning a value to it like Boolean b =true; it threw an error saying incompatible types.
    What Java version?

    db

  3. #3
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

    Default

    The java version is 1.5

  4. #4
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    You are talking about the Boolean wrapper classes.

    Have a look at this simple example : Java Boolean

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  5. #5
    mlad is offline Member
    Join Date
    Mar 2010
    Posts
    22
    Rep Power
    0

    Default

    This may be much simpler than is required, but in Java the primitive boolean type is not capitalised.

    Java Code:
    boolean capitalised;
    
    capitalised = false;

  6. #6
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    7

    Default

    Quote Originally Posted by maya700 View Post
    ... when i tried declaring a variable like Boolean b and tried assigning a value to it like Boolean b =true; it threw an error saying incompatible types.
    The statement Boolean b = true; is quite legal in Java these days (1.5 and later).

    Either your Java language level setting is incorrect, or you are using Java 1.4 or earlier. I suspect the former.

  7. #7
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    To really make it more clear to yourself, install Java 6 at your machine, set proper path in environment variables and try to compile your Java file with various -source options. They will show you the difference.

    Suppose your file is named Hello.java, the
    n
    Java Code:
    javac -source 1.4 Hello.java //would give you incompatible types error for Boolean b = true.
    
    javac -source 1.5 Hello.java //would compile just fine
    
    javac -source 1.6 Hello.java //would compile just fine

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  8. #8
    maya700 is offline Member
    Join Date
    Jun 2010
    Posts
    45
    Rep Power
    0

    Default

    Thanks a lot guys. It works. Thank you once again all.

  9. #9
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by maya700 View Post
    Thanks a lot guys. It works.
    Glad to know that... :D
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. Replies: 10
    Last Post: 04-06-2011, 04:45 PM
  2. Table Data Type
    By sehudson in forum New To Java
    Replies: 12
    Last Post: 03-14-2011, 03:28 AM
  3. Matrix Data Type
    By fraB3422 in forum New To Java
    Replies: 7
    Last Post: 02-27-2011, 02:08 AM
  4. how to set NVarchar data type
    By edi.gotieb in forum JDBC
    Replies: 9
    Last Post: 05-19-2010, 01:13 PM
  5. sychronized data type
    By java girl in forum Threads and Synchronization
    Replies: 3
    Last Post: 02-13-2009, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •