الانتقال إلى المحتوى

كلمة this

مُقدَّم
ورقة عمل
درس فيديو لهذا الموضوع افتح صفحة الفيديو
7:20

إنشاء الفئة

إليك طالب، مخزن كثلاث متغيرات منفصلة: اسم، سنة، ودرجة. هذا يعمل. الآن أضف ألف طالب. تحتاج ثلاثة آلاف متغيرات…

سرد باللغة الإنجليزية · ترجمة نصية بالإنجليزية و中文 يمكنك التبديل بينهما

في هذا الدرس

درس فيديو
English

A parameter can hide the field it should update

  • An object has name "Ada". setName(String name) runs name = name; with the argument "Bo".
  • Both unqualified names refer to the parameter, so the object still has "Ada". this.name = name assigns the parameter value to the field instead.
A parameter can hide the field it should update: in setName(String name), name = name assigns the parameter to itself, so the object keeps "Ada"; this.name = name assigns the parameter value "Bo" to the field

ورقة عمل

تسجيل الدخول أو إنشاء حساب

IGCSE, A-Level & AP