Thread View: be.comp.programming
2 messages
2 total messages
Started by alias
Mon, 16 May 2005 15:33
[JAVA] - prioriteitsregels
Author: alias
Date: Mon, 16 May 2005 15:33
Date: Mon, 16 May 2005 15:33
77 lines
3927 bytes
3927 bytes
This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C55A3C.B4A6E020 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Haakjes hebben toch de hoogste prioriteit. Waarom krijg ik dan toch 2 verschillende resultaten=20 voor 'dezelfde' bewerking ? Blijkbaar wordt bij a) de eerste term toch ge=EBvalueerd naar 10 ipv eerst de tweede term tussen haakjes uit te werken.=20 int x =3D 10; a) x =3D x + (x =3D 3); -> resultaat x =3D 13; b) x =3D (x =3D 3) + x; -> resultaat x =3D 6; Iemand een antwoord ?=20 Bedankt !=20 ------=_NextPart_000_000E_01C55A3C.B4A6E020 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DFixedsys size=3D1>Haakjes hebben toch de hoogste=20 prioriteit.</FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1>Waarom krijg ik dan toch 2 = verschillende=20 </FONT><FONT face=3DFixedsys size=3D1>resultaten </FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1>voor 'dezelfde' bewerking ? = Blijkbaar wordt=20 bij a)</FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1>de eerste term toch ge=EBvalueerd = naar 10 ipv=20 eerst de tweede</FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1>term tussen haakjes uit te=20 werken. </FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1></FONT> </DIV> <BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px"> <DIV><FONT face=3DFixedsys size=3D1>int x =3D 10;</FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1></FONT> </DIV> <DIV><FONT face=3DFixedsys size=3D1>a) x =3D x + (x = =3D=20 3); -</FONT><FONT face=3DFixedsys = size=3D1>> resultaat x=20 =3D 13;</FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1></FONT> </DIV> <DIV><FONT face=3DFixedsys size=3D1>b) x =3D (x = =3D 3) +=20 x; -> </FONT><FONT face=3DFixedsys = size=3D1>resultaat x =3D=20 6;</FONT></DIV> <DIV><FONT face=3DFixedsys size=3D1></FONT> </DIV></BLOCKQUOTE> <DIV dir=3Dltr><FONT face=3DFixedsys size=3D2>Iemand een antwoord ? = </FONT></DIV> <DIV dir=3Dltr><FONT face=3DFixedsys size=3D2></FONT> </DIV> <DIV dir=3Dltr><FONT face=3DFixedsys size=3D2>Bedankt ! </FONT></DIV> <BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px"> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV></BLOCKQUOTE> <DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML> ------=_NextPart_000_000E_01C55A3C.B4A6E020--
Re: [JAVA] - prioriteitsregels
Author: Aquila
Date: Mon, 16 May 2005 17:50
Date: Mon, 16 May 2005 17:50
23 lines
1725 bytes
1725 bytes
alias wrote: > int x = 10; > > a) x = x + (x = 3); -> resultaat x = 13; > evaluatie van links naar rechts: linkse term: x blijft 10 rechtse term: returnvalue 3, x = 3 10 + 3 = 13 > b) x = (x = 3) + x; -> resultaat x = 6; evaluatie van links naar rechts: linkse term: returnvalue 3, x = 3 rechtse term: x is nu 3 3 + 3 = 6 Maar natuurlijk is je code al bijzonder ingewikkeld als je dit soort statements begint te gebruiken... -- "May the source be with you"
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads