Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Java Generics Introduction --HashMap summary     - Android Send HTTP POST requests (Programming)

- System-level alias vs Oracle ADR functionality (Database)

- Echo Command Examples (Linux)

- Piostat - Monitoring and Statistics Linux process (Linux)

- Practical top command (Linux)

- CentOS 6.0 system security level (Linux)

- Linux Security Raiders SSH tools SCP uses examples to explain in detail (Linux)

- Tomcat configuration memory and remote debug port (Server)

- Hazelcast integration with MongoDB (Database)

- How VirtualBox and VMware virtual machine conversion (Linux)

- Oracle bug Ora-04043 (Database)

- Let your PHP 7 faster (GCC PGO) (Linux)

- CentOS6.7 text installation system (Linux)

- Android Studio commonly used shortcuts and how to follow the Eclipse Shortcuts (Linux)

- BGP routers want to play it by CentOS (Linux)

- Java annotations entry automatically generates SQL statements (Programming)

- CentOS6 installation configuration rsh (Server)

- Web database security tips (Linux)

- Linux System Getting Started Learning: Change the name of the network interface on CentOS7 (Linux)

- Oracle Database import and export combat (Database)

  Java Generics Introduction --HashMap summary
  Add Date : 2018-11-21      
  Today, in the programming, you need to use to store and transfer data Hashmap, he found himself learning Java so long, in fact, generics are still poorly understood, search tidied HashMap use.

HashMap declaration initialized because generic reasons, from the two key and value parameters are required for specific types of methods can be put to use to transfer data to a HashMap,

HashMap data = new HashMap ();

data.put ( "Apple", 100);

data.put ( "pear", 200);

data.put ( "grape", 300);

data.put ( "banana", 400);

data.put ( "lychee", 500);

HashMap using my degree is its focus traversal algorithm ,, its traversal algorithm there are two, and you can use KeySet entrySet to traverse, the core code is as follows:

The first: using EntrySet

Map map = new HashMap ();

Iterator iter = map.entrySet () iterator ().;

while (iter.hasNext ()) {

Map.Entry entry = (Map.Entry) iter.next ();

Object key = entry.getKey ();

Object val = entry.getValue ();


High efficiency, it will be easy to use in this way!

The second: use the KeySet

Map map = new HashMap ();

Iterator iter = map.keySet () iterator ().;

while (iter.hasNext ()) {

Object key = iter.next ();

Object val = map.get (key);


Some team is inefficient, in this way it has the advantage that it can be worth based on what you want you want to key values, more flexibility! !

The two ways to traverse fact there is a difference, for keySet actually traversed twice, once into iterator, once to remove the key from the hashmap for the value.

The entryset just traversing the first, it is the key and value are placed in the entry, so fast.
- How Datadog monitor Nginx (Server)
- CentOS 6.5 set under Oracle 12c at startup (Database)
- Fedora 21 setting boot script (Linux)
- CentOS 6.4 dial-up Raiders (Linux)
- Why do I prefer Git (Linux)
- Rails project prepared some tips small experience (Linux)
- Manually generate AWR reports (Database)
- About MongoDB query method according to fuzzy field (Database)
- Spring loaded container finishes executing a method (Programming)
- CentOS6 installation configuration rsh (Server)
- MySQL & NoSQL - Memcached widget (Database)
- Modular JavaScript (Programming)
- Use web2py + uWSGI + Nginx Web server built on Linux (Server)
- Virt Related Command Summary (Linux)
- Formatted output printf command (Programming)
- Ubuntu 14.10 Apache installation and configuration (Server)
- Linux, Eclipse flash back and reinstall the JDK methods (Linux)
- shell-like program (Programming)
- Linux Command study manual - GPG command (Linux)
- How to view the Linux QPS (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.