Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25634

Re: Why “new”?

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Why “new”?
References <iii71v$3ud$1@lust.ihug.co.nz> <iiiqnu$ev4$1@lust.ihug.co.nz>
Message-ID <VIc3p.40513$Tg1.24745@newsfe13.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-02-05 09:59 -0400

Show all headers | View raw


On 11-02-05 02:29 AM, Lawrence D'Oliveiro wrote:
> In message<iii71v$3ud$1@lust.ihug.co.nz>, Lawrence D'Oliveiro wrote:
>
>> How many hundreds of times a day do Java programms write something like
>>
>>      classname varname = new classname(args);
>
> And this just gets worse with generic types, e.g.
>
>      GenericClass<Type1, Type2>  x = new GenericClass<Type1, Type2>;
>
> because Java has no typedefs like C++:
>
>      typedef GenericClass<Type1, Type2>
>          ShortName;
>
> Or you could probably fudge it:
>
>      class ShortName extends GenericClass<Type1, Type2>  {}
>
Well, no, you probably couldn't fudge it. In fact, it would take you 
like 2 minutes with an editor and shell/command prompt to find out that 
two Java source files with

public class GenericClass<X, Y> { }

and

public class ShortName extends GenericType<X, Y> { }

don't compile. Something like

public class ShortName extends GenericClass<String, Integer> { }

does work (akin to a "specialization"). Perhaps you can discover why 
your general idea had a problem.

AHS

-- 
We must recognize the chief characteristic of the modern era - a 
permanent state of what I call violent peace.
-- James D. Watkins

Back to comp.lang.java.programmer | Previous | Next | Find similar


Thread

Re: Why “new”? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-02-05 09:59 -0400

csiph-web