Operator precedence
Në shqip: Përparësia e operatorëve
ShpjegimiSQ
Përparësia vendos cili veprim bëhet i pari: * dhe / para + dhe -, krahasimet para && dhe ||. Kur s'je i sigurt, vendos kllapa — kodi bëhet edhe më i lexueshëm.
EnglishEN
Precedence decides which operation happens first: * and / before + and -, comparisons before && and ||. When unsure, add brackets — the code becomes more readable too.
Si ta mendosh
Si rregulli i matematikës në shkollë: shumëzimi para mbledhjes, përveç kur ka kllapa.
Lexoje në anglisht
Like the maths rule at school: multiplication before addition, unless there are brackets.
Shembull kodic
int a = 2 + 3 * 4; // 14, jo 20
int b = (2 + 3) * 4; // 20
if (x & 1 == 0) {} // kujdes: == bëhet para &