نوشته شده توسط
yasemi
map چیه لطفا با مثال توضیح دهید مثلا یه آرایه دوبعدی چطور تعریف میشه و چطور جستجو میشه
ممنون
اگر منظور شما رو درست متوجه شده باشم، Map یا Dictionary، یک مدل از Data-structure ها هستند، همانند Array-list با این تفاوت که شما در یک ArrayList با شماره index یک element به آن اشاره میکند، ولی در Dictionary یا همان Map هر Element یک key برای دسترسی دارد که اون key میتواند از نوع object باشد و unique است.
//Java Code
Dictionary dic = new Dictionary();
//let's assume that student class is already written
dic.put("Asghar",new Student("Asghar",104545,"Asghar@asghar.com"));
// And also I add lot's of other things
// Now if I planned to retrieve the student object blongs to asghar,
// I don't ask that element by any index number like in array-list
//simply I ask dictionary class by the key, which in this case is the STring object "Asghar"
Student ret = dic.get("Asghar");
امید وارم کمک کرده باشه.