محاضرة 2
Operators, Conditionals, and Loops
العمليات الحسابية، جمل التحكم، والحلقات التكرارية في Java.
يلا نشوف الملخص
📖 Lecture 2: Type Casting, Operators, and Conditions
- Type Casting: Converting one primitive data type into another [4].
- Widening Casting (Automatic): Converting a smaller type to a larger type (e.g.,
inttodouble) [4]. - Narrowing Casting (Manual): Converting a larger type to a smaller type by placing the target type in parentheses (e.g.,
(int) 9.78), which truncates the decimal [5].
- Widening Casting (Automatic): Converting a smaller type to a larger type (e.g.,
- Operators: Java includes Arithmetic operators (
+,-,*,/,%,++,--) [6] and Assignment operators (like=,+=) [6]. - Conditional Statements:
ifandelseblocks execute code based on a true/false condition [7]. Nested conditions allow placingifstatements inside otherifstatements [7].- Ternary Operator: A shorthand for
if-elsewritten asvariable = (condition) ? expressionTrue : expressionFalse;[8]. - Switch Statement: Evaluates a single variable against multiple
casevalues [9]. It usesbreakto stop execution anddefaultfor unmatched cases [9].
- User Input: The
Scannerclass (fromjava.util.Scanner) is used to read inputs likenextInt()andnextDouble()[10, 11].
في نقطة مش واضحة؟ بطبط موجود!
اسأل بطبط عنها