java - How to make my HashTable work on for a specific type -


i need create hashtable project.

here how define hashtable is:

public class studenthashtable<name, dateofbirth> {  } 

the way create hashtable following:

studenthashtable<string,integer> hashmap = new studenthashtable<string,integer>(); 

as stands now, work object has key of string type , value of integer type. need think can force hashtable accept objects of type student has key of string type , value of integer type?

if want customized hashmap only accept class student, odd request collections should generic usually, following. make setters work class student. way guaranteed not able accept except want.

example:

public void put(student student){...}  public void putall(student... students){...} 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -