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. layout xml reuse

Hi

    How can i  use the same layout folder "res/layout-fa" for
languages "arabic ,hebrew" .Without creating seperate folders like
"layout-ar ,layout-iw"

-- 

2. is GLSurfaceView life-cycle the same as Activity that own it ?

i'v found one solution, the key point is that if you destroy
GLSurfaceView before it stops running,it will raise errors(not
responsible)
i have used to destroy the GLSurfaceView immediately followed by
GLSurfaceView.onPause , the GLSurfaceView hasn't stoped runnnig at
that time ,and not destroyed the EGL enviroment(something like
EGLSurface,EGLContext...and so on).

so i use "postDelayed" to do that things about 50 millisecond later.
it works well!

but that seems not a very good approach for me ,because 50 millisecond
is just a probably estimation. maybe 30 or 20 could also work .



-- 

3. CM 4.2.

4. Isi email cuma : null

5. Ndrive - Maap

6. Can't receive broadcast "PACKAGE_ADDED"

7. is GLSurfaceView life-cycle the same as Activity that own it ?