السلام عليكم
ما الفرق بين Public, Public Static , Private , Static ؟؟؟
ارجو التوضيح ....
شكرا ً
السلام عليكم
ما الفرق بين Public, Public Static , Private , Static ؟؟؟
ارجو التوضيح ....
شكرا ً
إيلاف كتب:السلام عليكمما الفرق بين Public, Public Static , Private , Static ؟؟؟
ارجو التوضيح ....
شكرا ً
very nice question
this question very popular as a multupile choice in the exams ("Yani hada alsoaal dayman yati fi al imtahaan");
Public: No restriction member marked public are visible to any method of any class
Private : the member in class A that are marked Private are accessible only to methods of class A
Protected: the members in class A that are marked protected are accessible to methods of class A and also to methods of calsses derived from class A
what about Static ???
thank you
Static
تعنى الاتى
لو عملت اى function
ستاتيك فلن تستطيع ان تنادى عليها الا من خلال اسم الكلاس اللى هيا فيه وخلى بالك ان فى الـ main لو هاتعمل اى فانكشن يبقى لازم تكون استاتيك لأن الـ Main استاتيك ومش هاتشوف غير الاستاتيك وياريت اكون وضحت الفكره او وصلت
لا أسأل عن طريقة نداء الداله إنما أعني ماذا تعني static و كيف تعمل ؟؟
اذا كان لدينا متغر static و ليكن عداد في داله معينه فإنه يحتفظ بآخر قيمة و عند نداء الداله مره أخرى يقوم بالعد بعد آخر رقم و صلنا إليه ؟؟؟ ماذا عن الداله اذا كانت static كيف تعمل ؟؟؟
اذا كانت الداله private فهذا يعني انها لا تستخدم الا من قبل الكلاس نفسه ... بنفس الطريقه اريد ان اعرف ماذا يعني static ???
ما الفرق بين static void main
و
public static void main
لا أعرف اذا كان سؤالي واضح ......
شكرا ....
تم تعديل هذه المشاركة بواسطة إيلاف في 18 أبريل 2008 في 02:06
Static means that the function is called without instantiating an instance of the object on which it resides. It has nothing to do with scope, the Main method must be static because it is the entry point to your applicaiton, and therefore cannot be tied to an instance of an object.
المعنى غير واضح و لكن ما فهمته
أن الداله static تعني أن ال lifeTime للداله هو طوال وقت البرنامج لهذا يجب أن تكون ال main ستاتيك صحيح ؟؟؟
A static member belongs to the class rather than to the objects of the class. Hence static members are also known as class members and non-static members are known as instance members. class MyClass
{
public static int x;
public static int y = 20;
}
When we declare a static field inside a class, it can be initialized with a value as shown above. All un-initialized static fields automatically get initialized to their default values when the class is loaded first time.
تأسف إدارة الفريق العربي لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة استخدام البحث قبل السؤال.
قواعد طرح المشاركات
تأسف إدارة الفريق العربي لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة استخدام البحث قبل السؤال.
قواعد طرح المشاركات
هذا الموضوع مغلق.