This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Collection  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I wanted to store set of information like employee number, employee name, and employee address what class in the collection framework do i have to use so that when i search on the employee number, it would give me the employee name and address, could somebody pls help me with some code.
Thanks
Chris
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

have a employee class to store all employee related values in it.
Since u plan a search on the employee number,
Use java.util.Hashtable and use the employee number as the key there with employee class instance as the value.
So u need to wrap the key in Integer class though (java problem :-(, removed in C# though!).
class Employee{
String name;
String address;
int empNo;
}
Hashtable h = new Hashtable();
h.put(new Integer(empNo),
new Employee(//supply name/address to constrctor));
h.put(new Integer(empNo),
new Employee(//supply name/address to constrctor));
//repeat.
Now h.get(empNo) w'd get u the details corresponding to that employee.
karthik.
 
Chris Chua
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That one would really work thanks very much Karthik Gutu
Chris
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!