Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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
 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!