java - Why can't global variables and parameter variables in a constructor have the same name? -


public class listnode { listnode next; int data;  listnode (int data) {     next = null;     this.data = data; } 

the above code works.

    public class node<e> implements position<e> {     private e element;     private node<e> left, right, parent;      public node<e> (e element, node<e> parent, node<e> left, node<e> right) {      } } 

this 1 doesn't.

i realized it's because constructors can't include generic type declaration, or it's called. <e> shouldn't in constructor.

the problem parameter e in declaration there no need because exists in type definition:

node(e e, node<e> parent, node<e> left, node<e> right) 

Comments

Popular posts from this blog

python - Installing PyDev in eclipse is failed -

PHP OOP-based login system -

c# - Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment -