Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
null you have, ... it null you don't
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

null you have, ... it null you don't



Here's a fun one. Using java 1.4.2 on my nifty new ibook this fills the
Vector v with nulls:

String s1[] =
{"g","gt","f","a","z","e","qw","th","lslslslsl","this or that","this and
that","1123","#4lskdjf","asdf","fdsa","zxq","zyx"};

String o = "somekey";
Vector v = new Vector();

for(int x=0; x<s1.length; x++) {
HashMap hm = new HashMap();
v.add( hm.put(o, s1[x]) );

if (v.get(x) == null) System.out.println("wowzers");
}
But this doesn't:

String s1[] =
{"g","gt","f","a","z","e","qw","th","lslslslsl","this or that","this and
that","1123","#4lskdjf","asdf","fdsa","zxq","zyx"};

String o = "somekey";
Vector v = new Vector();

for(int x=0; x<s1.length; x++) {

HashMap hm = new HashMap();
hm.put(o, s1[x]);
v.add( hm );

if (v.get(x) == null) System.out.println("wowzers");
}


I'd love to know if this is a bug or by design!

Perhaps my iBook is overheating....


-----------------------------------------------------
Terrance Davis
Software Engineer
www.genedavissoftware.com
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.