Skip to content

Instantly share code, notes, and snippets.

@kapv89
Last active December 17, 2015 22:48
Show Gist options
  • Select an option

  • Save kapv89/5684342 to your computer and use it in GitHub Desktop.

Select an option

Save kapv89/5684342 to your computer and use it in GitHub Desktop.
Compile time error
public class Gen {
public static void main(String[] args) {
Foo<Integer> a = new Foo<Integer>(123);
// Baz b = new Baz("aha");
System.out.println(a.bar.toString());
// System.out.println(b.bar);
}
}
class Foo<T> {
public T bar;
public Foo(T bar)
{
this.bar = bar;
}
}
class Baz extends Foo<String> {
}
/**** Error ****/
Gen.java:27: error: constructor Foo in class Foo<T> cannot be applied to given types;
class Baz extends Foo<String> {
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
where T is a type-variable:
T extends Object declared in class Foo
1 error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment