جافا Java
6.34K subscribers
212 photos
18 videos
81 files
269 links
ليس عيبًا ألا تعرف شيئًا، ولكن العيب انك لا تريد أن تتعلم
Download Telegram
equals مقابل == مع السلاسل
equals vs == with Strings
String s1 = new String("java");
String s2 = new String("java");
System.out.println(s1.equals(s2) + "," + (s1 == s2));
أي عبارة صحيحة عن String و StringBuilder؟
Which is true about String vs StringBuilder?
ماذا يطبع جمع عناصر ArrayList؟
What does this ArrayList code print?
import java.util.*;
List<Integer> xs = new ArrayList<>();
xs.add(1);
xs.add(2);
System.out.println(xs.get(0) + xs.get(1));
الوراثة مع مُنشئ أب مُعَلَّم
Inheritance with parameterized base constructor
class Base { Base(int x) {} }
class Child extends Base { }
الفرق بين abstract و interface
Abstract class vs interface
مستوى الوصول عند إعادة التعريف
Access level when overriding
التعامل مع الاستثناءات في finally
Try-catch-finally order
try {
int x = 1 / 0;
System.out.print("A");
} catch (ArithmeticException e) {
System.out.print("B");
} finally {
System.out.print("C");
}
1
الاستثناءات المُتَحَقَّقة (Checked)
Checked exceptions handling
void read() throws java.io.IOException {}
void m(){ read(); }
تفضيل التحويلات في 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);
ترتيب التهيئة: static ثم instance ثم constructor
Initialization order
class X {
static { System.out.print("S"); }
{ System.out.print("I"); }
X(){ System.out.print("C"); }
}
new X();
إخفاء الحقول (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);