About Question enthuware.ocpjp.v7.2.1270 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
kashyapa
Posts: 23
Joined: Thu May 08, 2014 5:27 am
Contact:

About Question enthuware.ocpjp.v7.2.1270 :

Post by kashyapa »

Why

Code: Select all

ArrayList<> list = new ArrayList<>();
does not work?

i tried out it, but it says;
java.lang.RuntimeException: Uncompilable source code - illegal start of type

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1270 :

Post by admin »

The whole point of generifying a class such as ArrayList is to specify what kind of objects will be stored/retrieved from it! What do you think you declaration means to the compiler?

HTH,
Paul.

RicardoK
Posts: 1
Joined: Mon Jun 22, 2015 1:56 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1270 :

Post by RicardoK »

Code: Select all

List<String> list = new ArrayList<>(); 
list.add("A");
The explanation says that this wont compile?

admin
Site Admin
Posts: 10386
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1270 :

Post by admin »

RicardoK wrote:

Code: Select all

List<String> list = new ArrayList<>(); 
list.add("A");
The explanation says that this wont compile?
On Java 7.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests