Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Java Generics Introduction --HashMap summary     - RHEL7 Apache MPM configuration (Server)

- Single Instance ASM under CRS-4124, CRS-4000 error handling (Database)

- Linux shell script under the use of randomly generated passwords (Programming)

- Java Concurrency -volatile keywords (Programming)

- Java open source monitoring platform Zorka basic use (Linux)

- Fedora 22 how to play rmvb mp4 mkv video files (Linux)

- Oracle 12C RAC on temporary table space Enlighten (Database)

- To install the latest version of the EPEL on CentOS 5.x or 6.x (Linux)

- Android Dynamic efficiency articles: a brilliant Loading Analysis and Implementation (Programming)

- C ++: Postmodern systems programming language (Programming)

- Eclipse 3.7.2 can not start solving under Ubuntu 14.04 (Linux)

- Linux environment Duplex (multi-machine) automatic mutual backup scheme (Linux)

- Eclipse installs support for Java 8 (Linux)

- Installation of Gitlab under Ubuntu (Linux)

- LogStash log analysis display system (Linux)

- Lenovo E431 notebook CentOS system is installed wireless network card driver (Linux)

- Four IDS intrusion detection tool under Linux environment (Linux)

- Database Blob data type conversion String (Programming)

- Which file system is most suitable for your Linux system (Linux)

- Linux Network Programming - non-blocking program (Programming)

  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.
- Recover accidentally deleted Nginx logs (Server)
- Ubuntu and derivative users to install the system launcher SimDock 1.3 (Linux)
- Linux System Getting Started Learning: In RedHat Linux driver compiled Ixgbe (Linux)
- Linux with Windows Explorer as a security system (Linux)
- UNIX and class UNIX system security check notes (Linux)
- Macro Analysis Performance: PHP Performance Analysis and Experiment (Programming)
- Linux System Getting Started Learning: The Linux log (Linux)
- Android system source code and compile the kernel source code (Programming)
- Linux installation and error under codeblocks exclude [Ubuntu 10.04] (Linux)
- Ten to improve the efficiency of the Linux bash tricks (Linux)
- Redmine Installation (Linux)
- Scope of variables in C # (Programming)
- CentOS install Redis (Database)
- GDB remote connections RX Probe online debug program (Programming)
- See Shell Script Linux Server network traffic (Server)
- Revive Adserver ad server installation on Ubuntu 15.04 / CentOS7 (Server)
- Configuration based on open source Lucene Java development environment (Server)
- Oracle 11g user rights management study notes (Database)
- ogg start being given libnnz11.so: can not open shared object file (Database)
- Linux Shell introduces (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.