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();

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

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. How to change border color for EditText?

Hi, all!

  I want to do "White Theme" in my application (black text on a white
background). I changed bgcolor for controls to white then borders of
EditTexts makes themselves invisibles. How to paint borders of
EditText to black color?



2. Strided buffer support in Camera preview callback


Does the Google API for Camera preview callback support passing stride-d
buffer (Width of the buffer is larger than the image data present in the
buffer) from the Camera Service level?

I see the below signature that applications are provided to access the
preview data from Camera.

Is it possible to communicate the stride somehow to the applications so that
applications can skip the padding bytes at the end of every line?

        public void onPreviewFrame(byte[] data,
                                   android.hardware.Camera camera) {



3. Image effectsef

4. AIDL Compiler for C/C++

5. a global high score board for android games - aHighScore

6. Multiple Icon on Android App

7. AutoCompleteTextView and show suggestions