Results 1 to 3 of 3
  1. #1
    arnab321 is offline Member
    Join Date
    Oct 2008
    Posts
    40
    Rep Power
    0

    Default What is the difference between

    ...provided that a and b are booleans

    i tried in an if statement-
    a=false;b=true;

    if{

    code does not execute

    }

    if(!(a&&b)){

    strangely, this will get executed. why?
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Your first if statement has no boolean test. In fact this shouldn't even compile:
    Java Code:
    if {
      //...
    }
    While this:
    Java Code:
    if(!(a&&b)){
     //..
    }
    has a boolean test immediately after the if and should compile and work fine. This will execute if not in the intersection of a and b (thinking in Venn diagram mode).

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Basically this is all about if-else combination.

    arnab321 just use two if statements in that code, so there are executing separately/independently on each other.

Similar Threads

  1. difference between swing and swt?
    By makpandian in forum AWT / Swing
    Replies: 1
    Last Post: 12-31-2008, 07:12 PM
  2. what is the difference between jsp and jsf?
    By makpandian in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-31-2008, 05:55 PM
  3. difference
    By nishant in forum New To Java
    Replies: 2
    Last Post: 09-17-2008, 06:04 PM
  4. Difference between ASP and JSP
    By barney in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:15 AM
  5. difference between this and super
    By mrark in forum New To Java
    Replies: 1
    Last Post: 06-27-2007, 05:23 PM

Posting Permissions

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