سلامي للجميع
أنا أسف بدأت مشاركاتي بسؤال بس بتمنى انكم تتحملوني
عندي برنامج مؤلف من 2 classes
المطلوب شرح البرنامج وايضاح النتائج التي تضهر بعد Compiler
انا وضعت البرنامج على رابط ورغم ذلك سأقوم بكتابته
public class References {
public static void setToTen(int i) {
i = 10;
System.out.println("inside of the method - the worth of int-date: " + i);
}
public static void setToTen(MyClass mc) {
mc.setValue(10);
System.out.println("inside of the method - the worth of MyClass-Objekt: " + mc.getValue());
}
public static void main(String[] args) {
int i = 5;
setToTen(i);
System.out.println("outside of the method - the worth of int-date : " + i);
MyClass mc = new MyClass();
mc.setValue(5);
setToTen(mc);
System.out.println("outside of the method - the worth of MyClass-Objekt: " + mc.getValue());
}
}
وهنا الclass 2
public class MyClass {
private int value = 0;
public int getValue() {
return this.value;
}
public void setValue(int value) {
this.value = value;
}
}
ارجوا تساعدوني في فهم هدا البرنامج لانه مطلوب مني شرحه يوم الاثنين القادم
فهناك عدة نقاط لم افهمها
1. لمادا جزئنا البرنامج الى 2 كلاسس
2.ولمادا قمنا بتعريف العدد i مرتين في الكلاس References ولماذا اعطيناه قيمة اخرى 5
3.وماذا تعني MyClass mc في الميثود SetToTen
البرنامج هنا
ارجو منكم عدم كرهي لكترت اسألتي ولكنني مازلت مبتدئ في الجافا بالاضافة الى انني ادرسها بلغة بعيدة كل البعد عن لغتنا