Programming Basics SQL HTML CSS JavaScript Python C++ Java JavaFX Swing Problem Solving English English Conversations Computer Fundamentals Learn Typing

كيف تم تحويل قيمة الـ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؟

تعليقات 1

أضف تعليق

يجب تسجيل الدخول حتى تتمكن من إضافة تعليق أو رد.