جافا Java
Відкрити в Telegram
ليس عيبًا ألا تعرف شيئًا، ولكن العيب انك لا تريد أن تتعلم
Показати більше6 181
Підписники
Немає даних24 години
-177 днів
-6830 день
Архів дописів
6 180
📢 Advertising in this channel
You can place an ad via Telega․io. It takes just a few minutes.
Formats and current rates: View details
6 180
❓ switch مع break
switch with break
int n = 1;
switch (n) {
case 1: System.out.print("X"); break;
default: System.out.print("Y");
}6 180
❓ اقتران else بالأقرب
else pairs with nearest if
int x = 0, y = 10;
if (y > 0)
if (x == 1) System.out.print("A");
else System.out.print("B");6 180
❓ do-while تُنفَّذ مرة على الأقل
do-while runs at least once
int i = 5;
do { i++; } while (i < 5);
System.out.println(i);6 180
❓ ما ناتج الجمع مع break؟
What is the output with break?
int sum = 0;
for (int i = 1; i <= 5; i++) {
if (i == 4) break;
sum += i;
}
System.out.println(sum);6 180
❓ استخدام this للإشارة لحقل مُغَطّى
Using this to refer to a shadowed field
class T {
int n = 10;
void set(int n){ n = n; }
int get(){ return n; }
}
T t = new T();
t.set(5);
System.out.println(t.get());6 180
❓ إخفاء الحقول (Field Hiding)
Field hiding resolution
class A { int v = 1; }
class B extends A { int v = 2; }
B b = new B();
System.out.println(((A)b).v);6 180
❓ ترتيب التهيئة: static ثم instance ثم constructor
Initialization order
class X {
static { System.out.print("S"); }
{ System.out.print("I"); }
X(){ System.out.print("C"); }
}
new X();6 180
❓ تفضيل التحويلات في Overload
Overload preference (widening vs boxing vs varargs)
static void m(long x){ System.out.print("long"); }
static void m(Integer x){ System.out.print("Integer"); }
static void m(int... x){ System.out.print("varargs"); }
m(5);