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. listview scrollbar fade out

Listview shows a vertical scrollbar by default when the screen
overflows.
I'd like to have the scrollbar hidden and appears only when I scroll
the table.
How can I control it?

In the old SDK(m5), if I remeber correctly, the scrollbar fades in and
out by default when I touch the screen.  Is this a change in SDK
0.9+?  I cannot find any information in the SDK change list.

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

2. Calling Intent from Two Locations

Hi,

I am trying to call an intent to select someone from the contactlist
from 2 different places in my program.

In one activity class (my main one) I call:

                Intent i=new Intent(Intent.ACTION_PICK,
                Uri.parse("content://contacts/people"));
                startActivityForResult(i, PICK_REQUEST);


and I am able to catch the result of PICK_REQUEST in my
onActivityResult function, no problem.

When I try calling the same intent within another class, it still
tries to catch it in the
onActivityResult of the main class, not in the onActivityResult i
implemented in the 2nd class.

What am I doing wrong so I don't jump out of my other class (where
there's private data I want to access once I am done getting the
contact info).

Thanks,
Mark



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

3. I wonder How can I get or Import com.google.googlenav package

4. i18n problem

5. differences between emulator (1.0rc1) and actual device (g1)

6. How to load J2ME/CAB/SIS to android HTC G1

7. Help with cross compile of Android for G1 and flashing the image