Hi Shiva,
In line 8 "test = (i<10) | (j++>9);" --> its a Bitwise OR. so both i<10 and
j++>9 executed and is true. so test become true.

where in line 14 "test=(i<10) || (j++>9);" --> its a logical OR. In this
case if the 1st statement or condition is true it will not execute 2nd one.
So only (i<10) executed, not (j++>9). thats why value of j didn't change. if
you write the statement like "test=(i>10) || (j++>9);" the value of j will
change as (i>10) is false so it will execute (j++>9).


BR,
Deb

On Fri, Aug 14, 2009 at 6:41 AM, Chirutac Dumitru <chiru...@yahoo.com>wrote:

>
> because you display in row 17  the values of these variables, but in row 18
> you display the values of these variables and after you increment this
> variables. If you want change value before to display make the following
> way:
>
>   17. System.out.printl(j);//14
>   18. System.out.printl(++j);//15
>
> From: siva prasad <access2a...@gmail.com>
> Subject: [java programming] java Operators
> To: javaprogrammingwithpassion@googlegroups.com
> Date: Thursday, August 13, 2009, 11:11 PM
>
>
>    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 javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to