English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1st example---> a=b=2;

2nd ----> b=2;
a = ++b;

3rd example ---> b= 2;
a= b++;

thnx!! i need help!

2006-06-08 10:50:59 · 5 answers · asked by a_normal_grl 1 in Computers & Internet Programming & Design

5 answers

(she never SAID it was math)

At the 'end' of each example, the values in your variables 'a' and 'b'...

Ex 1: a = 2, b = 2
Ex 2: a = 3, b = 3
Ex 3: a = 2, b = 3

Your examples 2 & 3 use pre and postincrementation, which is common not only in Java but most programming languages.

Example 2 uses a 'preincrement' operator, so 'b' is incremented to 3 before its value is assigned to 'a'.
Example 3 uses 'postincrement', so the original value of 'b' (2) is assigned to 'a' before 'b' is incremented to 3.

2006-06-08 11:05:45 · answer #1 · answered by nadaclue_002 2 · 0 0

if a=b=2 then a=2 and b=2 so ab=2x2= 4

2006-06-08 10:53:48 · answer #2 · answered by rbrow112 3 · 0 0

i was never good at math im sorry

2006-06-08 10:52:39 · answer #3 · answered by Arods Bro (Durant4MVP) 6 · 0 0

this is not math ...this is JAVA ...& JAVA is stupid !

2006-06-08 10:53:36 · answer #4 · answered by Nihilist 3 · 0 0

idk! thanxs for da points anyway!!!!!!!!

2006-06-08 10:53:50 · answer #5 · answered by elkinluna_44 3 · 0 0

fedest.com, questions and answers