samedi 22 août 2015

What may be an instance of ParameterizedType?

After reading a documentation of ParameterizedType interface I thought that an example of ParameterizedType's instance can be any parametrized type such as col in my code:

  public class a0 {

     public static void main(String[] args) {

        Collection<String> col = new ArrayList<String>();
        col.add("a");
        col.add("b");
        col.add("c");

        assert col instanceof ParameterizedType; // line No. 10
     }
  }

But I get this:

Exception in thread "main" java.lang.AssertionError
at a0.main(a0.java:10)

Thus, what may be an instance of ParameterizedType?

I'd like to know this because I am trying to understand one greater program in which there is such a fragment:

public static void printType(Type type) {
...
if (type instanceof ParameterizedType) {
... }
}

But I don't know when a condition in if statement is true..





Aucun commentaire:

Enregistrer un commentaire