Here is what your code could look like.

public class TestOr {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int i = 0;
        int j = 10;
        boolean test = false;

        //demonstrate ||
        System.out.println("demonstrate ||");
        System.out.println("j = " + j + ", j++ = " + j++);//10
        test = (i < 10) || (j++ > 9);//11
        System.out.println("i = " + i + ", j = " + j);
        System.out.println("j++ = " + j++);//12
        System.out.println("j++ = " + j++);//13
        System.out.println("test = (i < 10) || (j++ > 9) = " + test);

        System.out.println();

        //demonstrate |
        System.out.println("demonstrate |");
        test = (i < 10) | (j++ > 9);//14
        System.out.println("i = " + i + ", j = " + j);
        System.out.println("j++ = " + j++);//14
        System.out.println("test = (i < 10) | (j++ > 9) = " + test);
    }
}


On Aug 14, 1:11 am, siva prasad <[email protected]> wrote:
>    1. public class TestOR {
>    2. public static void main( String[] args ){
>    3. int i = 0;
>    4. int j = 10;
>    5. boolean test= false;
>    6. //demonstrate ||
>    7. System.out.println(j++);//10
>    8. test = (i < 10) | (j++ > 9);//11
>    9. System.out.println(i);
>    10. System.out.println(j++);//12
>    11. System.out.println(j++);//13
>    12.  System.out.println(test);
>    13.  //demonstrate |
>    14.  test = (i < 10) || (j++ > 9);//14
>    15.  System.out.println(i);
>    16.  //System.out.println(j);//1
>    17.  System.out.println(j);//14
>    18. System.out.println(j++);//14
>    19.  System.out.println(test);
>    20.  }
>    21.  }
>
> O/p:
>
> 10
> 0
> 12
> 13
> true
> 0
> 14
> 14
> true
>
> I couldnt understand y the value of j didnt change in the lines 17 & 18 of
> the above program.
> Pls suggest.
>
> Thanks in Anticipation
> Shiva.

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to