Generics help
What will happen if i compile the foll code:
import java.util.*;
publicclass Gen
{
publicstaticvoid main(Strring [] ar)
{
Collection<Integer> arr=new ArrayList<Integer>();
ArrayList<Integer> arr1=new ArrayList<Integer>();
//[i] some elements are added [/i]
if(arrinstanceof Collection<Integer>)System.out.println("is an instance");
}
}
> OK fine. can anyone tell me why we get a compile time
> error on the following line:
It wont throw error !!!!
> if(arr instanceof Collection<Integer>)
>
>
>
> null
Well it wont throw error mate ?
> What will happen if i compile the foll code:
> > import java.util.*;
> public class Gen
> {
> public static void main(Strring [] ar)
> {
> Collection<Integer> arr=new ArrayList<Integer>();
> ArrayList<Integer> arr1=new ArrayList<Integer>();
> /[i] some elements are added [/i]
> if(arr instanceof
> Collection<Integer>)System.out.println("is an
> instance");
>
>
> }
> }
>
The only error I see is
public static void main([b]Strring[/b] [] ar)