Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.teledata-fn.de!feeder.news-service.com!postnews.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 16 Aug 2011 11:30:17 -0500 Date: Tue, 16 Aug 2011 09:30:15 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Using Enumerated Types as Array Indexes References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 19 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.203.65 X-Trace: sv3-tDRZ6F0eJaMGaO9qUOWO9iRohvS5zYIA6Q1lg6dIVWzoSor7NTVgM+R+ayyp47fV7gvtUCYSdw0u/Xb!VEQi24pOI0IDt2LIig6byrpGK7Zd2N5ljlIPfTdPVqPVh1RyvBj8DzDyrNFfRIFDg2eYgRhbs9AW!B15vxOSqfd2y/EltLyCR0FRFU+/3rfrjSO/lzDH/G6KVdw== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2020 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7137 On 8/16/2011 7:53 AM, KevinSimonson wrote: ... > Java is a pretty handy language in its own right. But in Ada one > could define arrays to be indexed by enumerated types. Can Java do > that? If not, why not? > > I wrote a piece of code that implements an array ofs, indexed > by objects of class, an enumerated type, that I'm including > below. Obviously the functionality of this class could be copied to > make it possible to create _virtual_ arrays of _any_ element class, > indexed by _any_ enumerated type. Isn't this precisely the thing > generics were designed for? But how does one write a generic class to > implement an array indexed by enumerated types? ... Why not use java.util.EnumMap? Patricia