Node( T itemArg, Node<T> nextArg ) {
this.item = itemArg;
this.next = nextArg;
}
Is this the right way to represent generic constructor
This is correct, as long as the parameter is specified in the class definition.
EDIT: Ensure item is an instance of T, and next is an instance of Node<T>.
public class Node<T> {
T item;
Node<T> next;
//your constructor
}
item should be an instance of T and next an instance of Node<T>.
fooArgand qualify the fieldthis.foo:foo = fooArg;, or renaming the parameter tofooand usingthis.foo = foo;, is more usual. But it isn't wrong to do it like this.