i have private member array of type generics , in constructor have parameter set size of array. how set private array size specified constructor parameter?
this have:
private t[] hashtable; public hashtable(int initsize){ // set hashtable size here }
this solution requires upcast object[]
.
public class hashtable<t> { private t[] hashtable; public hashtable(int initsize){ // set hashtable size here hashtable = (t[]) new object[initsize]; } }
Comments
Post a Comment