Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: jrobinss Newsgroups: comp.lang.java.programmer Subject: alias for Integer Date: Fri, 18 Nov 2011 06:50:42 -0800 (PST) Organization: http://groups.google.com Lines: 47 Message-ID: <21374513.220.1321627842805.JavaMail.geo-discussion-forums@yqmj32> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 64.208.49.21 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1321627960 8501 127.0.0.1 (18 Nov 2011 14:52:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 18 Nov 2011 14:52:40 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=64.208.49.21; posting-account=raMt9AoAAACPbWkv8OI-qo2nMs4SyD7X User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10041 Hi all, this is a simple question, so it may be silly... I am processing structures that contain integers, structures such as matrix= es used in statistical analysis. As I implement these as Maps of indexes, I= use the class Integer, as in // Map <- I'd like to remove this comment! public static Map myMap =3D ...; Now what I'd like is to write public static Map myMap =3D ...; The advantage is that the code is auto-documented, but even better that the= compiler will check that I never get mixed up in different indexes, by rel= ying on strong typing. Usually, I would do this by extending the relevant class. But here it's Int= eger, which is final. Questions:=20 1. is this a bad good idea, and I should proceed with Integer? 2. if not, how would you implement this? 3. is there any performance issue in defining my own classes instead of Int= eger? My current solution is to define my own classes for replacing Integer, such= as: public final class MatrixIndex { public final int value; public MyIndex(int i) {value =3D i;} } I won't benefit from autoboxing, then... :-( (I'm just hoping it doesn't break too much of the code, because even though= it's mine to break, I don't have infinite time) Note that (exceptionnally for me) performance *is* an issue here. I haven't= yet narrowed it down, but the code executes very slowly and eats up much t= oo much memory at the moment. I'm starting to optimize it, that's why I'm s= tarting with strongly typing it to prevent errors. thanks for any tips! JRobinss