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


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

Re: abbreviated generic syntax

NNTP-Posting-Date Tue, 19 Feb 2013 02:56:13 -0600
Date Tue, 19 Feb 2013 08:56:11 +0000
From lipska the kat <"nospam at neversurrender dot co dot uk">
Organization Trollbusters 3
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: abbreviated generic syntax
References <0h93i8pcopf17145fus96g7vams86hocat@4ax.com> <c1f51ff4-5827-4171-a60d-410e0582d98f@googlegroups.com> <6le5i8d6o3hsod9n20q6d15g36nb2vllin@4ax.com>
In-Reply-To <6le5i8d6o3hsod9n20q6d15g36nb2vllin@4ax.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
Message-ID <4K2dnVfP746wo77MnZ2dnUVZ7vSdnZ2d@bt.com> (permalink)
Lines 40
X-Usenet-Provider http://www.giganews.com
X-AuthenticatedUsername NoAuthUser
X-Trace sv3-NFuUmDHtb0Ngs2ay4+ycMZnkKmrM89J1AdzDQUatF9NvBtZZykiu5oPdHLts6XEdWVZlnzDzXy8xmd5!YQAc+EXrHmBVARRNoA4uago7VyvMXdGhMD1dUkz4siwe1DbLaMTUXHMcwbJLGKi786dPlcr7VYA=
X-Complaints-To abuse@btinternet.com
X-DMCA-Complaints-To abuse@btinternet.com
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 2505
Path csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail
Xref csiph.com comp.lang.java.programmer:22357

Show key headers only | View raw


On 18/02/13 23:35, Roedy Green wrote:
> On Mon, 18 Feb 2013 12:29:53 -0800 (PST), Lew<lewbloch@gmail.com>
> wrote, quoted or indirectly quoted someone who said :
>
>> The diamond operator distinguishes the generics usage.
>
> OK, that is obvious, but would it break any code?

Just to recap

1. ArrayList<String> a = new ArrayList<String>( 100 );

is quite clear

ArrayList<String> a = new ArrayList( 100 );

means you can do this and it compiles (1.6 and 1.7)

2. ArrayList<String> c = new ArrayList( 100 );
    c.add(new String("foo"));

but you will get a runtime exception if you try to do
Integer ops on the String

3. ArrayList<String> a = new ArrayList<>( 100 );

uses the 1.7 <> operator to allow the compiler to infer the type at
compile time from the type of the LHS, it's shorthand to allow you to
avoid having to type the generic params twice.

Given that generics is all about compile time type checking then I can't 
see anything breaking.

http://docs.oracle.com/javase/1.5.0/docs/guide/language/index.html

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

abbreviated generic syntax Roedy Green <see_website@mindprod.com.invalid> - 2013-02-17 20:26 -0800
  Re: abbreviated generic syntax Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-18 01:02 -0800
  Re: abbreviated generic syntax Barb Knox <see@sig.below> - 2013-02-18 22:41 +1300
    Re: abbreviated generic syntax Donkey Hottie <donkey@fredriksson.dy.fi> - 2013-02-18 12:58 +0200
    Re: abbreviated generic syntax Arne Vajhoej <arne@vajhoej.dk> - 2013-02-18 07:20 -0500
      Re: abbreviated generic syntax Arne Vajhoej <arne@vajhoej.dk> - 2013-02-18 07:27 -0500
  Re: abbreviated generic syntax Arne Vajhoej <arne@vajhoej.dk> - 2013-02-18 07:23 -0500
  Re: abbreviated generic syntax "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-02-18 19:33 +0000
  Re: abbreviated generic syntax BGB <cr88192@hotmail.com> - 2013-02-18 13:46 -0600
  Re: abbreviated generic syntax Lew <lewbloch@gmail.com> - 2013-02-18 12:29 -0800
    Re: abbreviated generic syntax Robert Klemme <shortcutter@googlemail.com> - 2013-02-18 22:49 +0100
      Re: abbreviated generic syntax Lew <lewbloch@gmail.com> - 2013-02-18 13:51 -0800
    Re: abbreviated generic syntax Roedy Green <see_website@mindprod.com.invalid> - 2013-02-18 15:35 -0800
      Re: abbreviated generic syntax lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-19 08:56 +0000
        Re: abbreviated generic syntax lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-19 12:30 +0000
      Re: abbreviated generic syntax Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-02-19 16:21 +0000
      Re: abbreviated generic syntax Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-02-19 11:38 -0600
      Re: abbreviated generic syntax Arne Vajhoej <arne@vajhoej.dk> - 2013-02-19 12:45 -0500
        Re: abbreviated generic syntax BGB <cr88192@hotmail.com> - 2013-02-19 15:20 -0600

csiph-web