I was playing around with java interfaces a little and tried to implement a stack.
However, as soon as I added the constructor I got a compiler error:
./DefaultStack.java:5: error: <identifier> expected
DefaultStack<T> () {
^
Here's my code:
public class DefaultStack<T> implements Stack<T> {
DefaultStack<T> () {
}
}
This is probably a really obvious mistake, but I'm kinda new to Java.
Remove <T>
from the constructor's signature.Write constructor exactly the same way you wrote other methods
DefaultStack()
{
}
More Info :how to create a generic constructor for a generic class in java?