Java Guru needed -- compiler bug?

by Zsolt Vasvari » Fri, 20 May 2011 16:50:55 GMT


Sponsored Links
 private void method(Collection<String> s)
    {
        // Nothing
    }


    private void caller()
    {
       // Complies fine
        Collection<String> s = Collections.emptyList();
        method(s);

       // Doesn't compile -- gives error message
       // The method method(Collection<String>) in the type Import is
not applicable for the arguments
       //  (List<Object>)
        method(Collections.emptyList());
    }


What's going on here?   The two statements look identical to me...

-- 



Re: Java Guru needed -- compiler bug?

by Nikolay Elenkov » Fri, 20 May 2011 16:57:01 GMT


 


I'm not going to pretend to be a guru, but here goes :)

It's a generic method:

public static final <T> List<T> emptyList()

In the second call there is no way to determine the type of the generic
parameter, so you get a list of Object.

-- 


Sponsored Links


Other Threads

1. eclipse adt plugin

I installed ADT on eclipse, as described in Android development
tutorials.

But when I configure everything and switch to DDMS view it does not
allow me to open/close any projects,
moreover, new project's directory gets created, but they do not get
listed in file explorer.
Even the devices that I create, do not get listed in devices section.

Has anybody come accross such a problem ?

Thanks and regards,
Parth

--~--~---------~--~----~------------~-------~--~----~

2. TOOLS.JAR

I'm using winXP.  Installed Android 1.5 as well as Eclipse.  However,
not sure if it's ANDROID or ECLIPSE that can't find the file
TOOLS.JAR.  Searched the ENTIRE hd, but can't find it.  PATHS are
correct(as far as I tell), but no luck. Any help would be
appreciated....Thanks in advance.....rc3...@gmail.com
--~--~---------~--~----~------------~-------~--~----~

3. Using setActualDefaultRingtoneUri

4. To Publish Priced Apps in Australia

5. Android Calendar / Google Maps integration

6. It doesn't works

7. Getting data from google search