Home page

HashMap in Java

Mar 25, 2013, 18:31
import java.util.HashMap;
import java.util.Map;
 
public class HashMapTest {
    public static void main(String[] args) {
	Person p1 = new Person(20);
	Person p2 = new Person(20);
 
	Map<Person, Person> m = new HashMap<Person, Person>();
	m.put(p1, p2);
	m.put(p2, p1);
	System.out.println(m.size());
    }
}
 
class Person {
    private int age;
 
    public Person(int age) {
	this.age = age;
    }
 
    @Override
    public int hashCode() {
	return age;
    }
}
3509 comments
Andrey

Ответ 2. Ключ будет братся из хешкода, тоесть из 20, они ссылаются на одну ячейку, ключи будут проверенный на равенство и не будут равны т. к. мы не переопределили иквел. Запишем торое значение.

Andrey

Забыл про коллизию написать )

EfremovaAurika91paymn

comprar is ato line

0584 at india is

TrevorTed

http:fullkade.com/Go/index.php?url=http:cialisdtk.com/
http:www.achperqld.org.au/__newsletter/307016/d9db27ea71f5d225e25fb54dc04aab52/external?url=http:cialisdtk.com
http://psjcu.com/__media__/js/netsoltrademark.php?d=cialisdtk.com
http://annesturetucker.com/__media__/js/netsoltrademark.php?d=cialisdtk.com
http://pjwakefield.com/__media__/js/netsoltrademark.php?d=cialisdtk.com
http:www.sports-central.org/cgi-bin/axs/ax.pl?http:cialisdtk.com
http://glhec.info/__media__/js/netsoltrademark.php?d=cialisdtk.com
http://rivieramayagolfcourse.com/__media__/js/netsoltrademark.php?d=cialisdtk.com
http:murano-club.biz/links.php?go=http:cialisdtk.com
http://porn-4-free.com/__media__/js/netsoltrademark.php?d=cialisdtk.com

MelnikovaZinaida93paymn

be cheap is soft uk

cf9d is order india

Donaldnax

http:northstarshoes.com/europe/out.php?url=http:viagraqaz.com
http://www.extremeclay.net/__media__/js/netsoltrademark.php?d=viagraqaz.com
http:www.s-school.com/toyo/1/yomi-search/rank.cgi?mode=link&id=62&url=http:viagraqaz.com
http://www.podfitness.com/__media__/js/netsoltrademark.php?d=viagraqaz.com
http:www.asaacamping.dk/pages/link_stat.asp?url=http:viagraqaz.com
http://courier-post.net/__media__/js/netsoltrademark.php?d=viagraqaz.com
https:www.bars-and-restaurants.com/go.php?url=http:viagraqaz.com
http://parrotbaycondos.com/__media__/js/netsoltrademark.php?d=viagraqaz.com
http://youngevityscience.com/__media__/js/netsoltrademark.php?d=viagraqaz.com
http:tristram.squarespace.com/process/Redirect?url=http:viagraqaz.com

EdwardMunny

http://whoozle.org/__media__/js/netsoltrademark.php?d=cialisqaz.com
http:ra-blog.net/outgoing.php?url=http:cialisqaz.com
http://glennsugden.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://drivertrainingaustralia.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://www.apexclinic.org/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://bast-gmbh.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://fvckstreetwear.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http:www.portaldobomretiro.com.br/redirect.asp?cod_cliente=26209&link=http:cialisqaz.com
http:www.hugeandnatural.com/crtr/cgi/out.cgi?id=68&tag=tubetop&trade=http:cialisqaz.com
http:www.pmates.com/te3/out.php?l=post&u=http:cialisqaz.com

Harrybed

http://mrrecipe.com/__media__/js/netsoltrademark.php?d=viagraqaz.com
http:www.stepnoe.ru/bitrix/rk.php?id=14&event1=banner&event2=click&event3=1+%2F+%5B14%5D+%5BPARTNERS%5D+%CE%F2%EA%F0%FB%F2%EE%E5+%EF%F0%E0%E2%E8%F2%E5%EB%FC%F1%F2%E2%EE&goto=http:viagraqaz.com
http://www.3elag.org/__media__/js/netsoltrademark.php?d=viagraqaz.com
https:www.orhanbhr.com/redirect.php?url=http:viagraqaz.com
http://airforcebuddy.com/__media__/js/netsoltrademark.php?d=viagraqaz.com
http:musicmax.su/?outlink=http:viagraqaz.com
http://highschoolrecords.pro/__media__/js/netsoltrademark.php?d=viagraqaz.com
http://www.lelalove.com/__media__/js/netsoltrademark.php?d=viagraqaz.com
http://columbusvacations.us/__media__/js/netsoltrademark.php?d=viagraqaz.com
http:www.lovelyclips.com/movies/go.php?id=952642_1&url=http:viagraqaz.com

Clarkanalf

http:erynok.com/redirect.php?site=http:cialisqaz.com
https:nstar-spb.ru/bitrix/redirect.php?event1=news_out&event2=http%3A%2F%2Fnstar-spb.ru%2F&event3=%D1%E0%ED%EA%F2-%CF%E5%F2%E5%F0%E1%F3%F0%E3%F1%EA%E8%E9+%EC%F3%E7%FB%EA%E0%EB%FC%ED%FB%E9+%E2%E5%F1%F2%ED%E8%EA%2C+%B99%28126%29%2C+%EE%EA%F2%FF%E1%F0%FC%2C+2015+%E3%EE%E4&goto=http:cialisqaz.com
http://bigbluemoose.me/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://hankthrash.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://structuralventilationsystems.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://holiday-pet.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://www.carnivalmiami.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://isitdelicious.net/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://eaglerings.us/__media__/js/netsoltrademark.php?d=cialisqaz.com
https:labinsk24.ru/bitrix/redirect.php?goto=http:cialisqaz.com

Clarkanalf

http:ashukindvor.ru/forum/away.php?s=http:cialisqaz.com
http://bizbuyer.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http:phototrans.pl/redirect.php?id=23&url=http:cialisqaz.com
http:affiliates.sideshowtoy.com/Tracker.aspx?aid=3179&href=http:cialisqaz.com/
http://dplusaequalsr.org/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://vatsan.org/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://starscapefestival.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http://poweradegames.com/__media__/js/netsoltrademark.php?d=cialisqaz.com
http:azarini.su/bitrix/redirect.php?event1=&event2=&event3=&goto=http:cialisqaz.com/
http://motorosjatekok.com/__media__/js/netsoltrademark.php?d=cialisqaz.com