كيف تم تحويل قيمة الـHashCode؟
السلام عليكم، لدي استفسار حول هذا المثال الذي تم شرحه في قسم أسئلة حول HashCode
المثال هو التالي:
public class Student {
String name;
float math;
float arabic;
float science;
public Student(String name, float math, float arabic, float science) {
this.name = name;
this.math = math;
this.arabic = arabic;
this.science = science;
}
@Override
public int hashCode() {
return (int) (math + arabic + science) / 3;
}
}
public class Student {
String name;
float math;
float arabic;
float science;
public Student(String name, float math, float arabic, float science) {
this.name = name;
this.math = math;
this.arabic = arabic;
this.science = science;
}
@Override
public int hashCode() {
return (int) (math + arabic + science) / 3;
}
}
مشكلتي هي أنني لم أفهم الكود الموجود في دالة hashcode();
الكود الذي لم أستطع فهمه هو return (int) (math + arabic + science) / 3;
هل تم تحويل قيمهم إلى النوع int
ثم تقسيمه على 3؟