课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
HashMap and HashSet operations in Java
- [Instructor] Let's take a look at how to use hash structures so we can build algorithms that work with key value pairs. We start off with an employee class. Each employee has a name, ID, and department. But eventually, this could include quite a bit of data. In the main function, we create three employees, giving them values for each piece of data. In order to organize and access each employee efficiently, we can choose a unique key out of these three attributes. It will serve as an identifier for each employee. Then, we can use the key to quickly retrieve a given employee's data. Two employees might have the same name and they might have the same department, but no two employees should have the same ID. So we'll use that as our key. The value in the key value pair will be the associated employee data. Let's use the HashMap type to store our employees by ID. The key is an integer. That's our ID data type, and we're storing employees as the value. We'll call it employees by ID. And…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。