Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Gene Wirchenko Newsgroups: comp.lang.java.programmer Subject: Re: Something Better than ArrayList Date: Tue, 21 Jun 2011 14:19:16 -0700 Organization: A noiseless patient Spider Lines: 55 Message-ID: References: <1337fe1a-2385-47c1-b966-9925f79d0ba3@j28g2000vbp.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx04.eternal-september.org; posting-host="7Qrvczazr82YckO5XW8Vtw"; logging-data="18191"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EuKWSAP0J9/JO3bcasVq4RGcnfJKaeG0=" X-Newsreader: Forte Agent 4.2/32.1118 Cancel-Lock: sha1:Xg6xVI5ZJT0ZKRbz42+Q0Y22lig= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5485 On Tue, 21 Jun 2011 02:22:46 -0700 (PDT), Paul Cager wrote: >On Jun 21, 6:34 am, Gene Wirchenko wrote: >> Dear Java'ers: >>      The name of the class is what I need.  I assume I can find the >> docs once I know what it is called. > >Others have already pointed you to java.util.Map, which answers your >immediate question. You might also want to have a look at the Java >"Collections" tutorial for more general information: >http://download.oracle.com/javase/tutorial/collections/index.html I found it rather dry, but did manage to write a proof-of-concept program for a symbol table. However, I have to check for duplication before put()ing. Is there a way to combine a Map and a Set to avoid this? For the Map static Map SymbolTable=new HashMap(); I would like to write something like static boolean TryToAdd ( String theKey, String theData ) { return SymbolTable.put(theKey,theData); } instead of static boolean TryToAdd ( String theKey, String theData ) { if (SymbolTable.containsKey(theKey)) return false; else { SymbolTable.put(theKey,theData); return true; } } Am I missing something or is this not supported? Sincerely, Gene Wirchenko