الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

static initializer ممكن احد يشرحلي عن

مغلق
بدأه CS25 في 19 نوفمبر 2006 · 2 رد · 599 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لوسمحتم قريت بكتاب شي اسمه static initializer بالجافا وبصراحه قريت فقره من الكتاب ماعرف شنو الشرح من الفقره ممكن اي احد يعرف عن static initializer يعطيني اي شرح عنه وهذي الفقره الي قريت فيها مع مثال عليه.

اقتباس
As you’ve already learned, instance variables are normally initialized inside

constructors. But what about class variables? How do we initialize them?

By the static initializer of a class is a JAVA routine that gets executed when the

class is loaded before the class gets used by the program. Static initializers

have weird syntax. As [8] explains it, a static initializer doesn’t take input

and doesn’t produce output, and there is really no need to name it since

we won’t be calling it. What is left from the class method declaration

is the word static and the curly brackets. And that’s exactly how you

define class initializers.

Let’s take an example. Here’s a class that needs to maintain an array

of powers of two. See how it initializes the array using a static initializer:

1 class Dummy {

2 final static int MAX = 10 ;

3 static long[] powers ;

4 static {

5 powers = new long[MAX] ;

6 powers[0] = 1 ;

7 for (int i = 1 ; i < MAX ; i++)

8 powers = powers[i-1]*2 ;

9 }

10 }

يعني بالمختصر شنو فايدة static initializer

#2
/index.ph...st&p=567181

سيمضي ركبنا العملاق لن يركع .. بإيمان لغير الحق لا يصدع

عزيزا شامخا كالمجد بل أروع .. فسجل أيها التاريخ ما تسمع :

فلسطين لنا الآمال والمطمع .. نعاهد أن نحررها وأن ترجع

ونقسم نستعيد الأرض أو نصرع .. ويبقى رمزنا الزيتون والمدفع

Palestine.gif

#3

شكرا اخت ناردين بس ممكن طلب اخير لو سمحتم

ماهي فائدة Autoboxing & Unboxing in java 5

هذا الموضوع مغلق.

مواضيع مشابهة