KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > util > LinkedHashMap

java.util
Class LinkedHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<K,V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>
See Also:
Top Examples, Source Code, removeEldestEntry(Map.Entry), constructor, Object.hashCode(), Collection, TreeMap, Hashtable

public void clear()
See Also:
V, HashMap, Map
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[293]Load data from DB into LinkedHashMap
By Anonymous on 2005/01/25 08:25:45  Rate
String SQL = "select aField, bField from aTable order by bField"; 
  
  
 Connection conn = null; 
 PreparedStatement pstmt = null; 
 ResultSet rs = null; 
 Map resultList = new LinkedHashMap (  ) ; 
  
  
 try  {  
     conn = DBUtil.getDBConnection (  ) ; 
     pstmt = conn.prepareStatement ( SQL ) ; 
  
  
     rs = pstmt.executeQuery (  ) ; 
  
  
     while  ( rs.next (  )  )   {  
         String a = rs.getString ( "aField" ) ; 
         String b = rs.getString ( "bField" ) ; 
  
  
         resultList.put ( a, b ) ; 
      }  
  
  
  }  catch ( SQLException se )   {  
     logger.error ( "Error retrieving aTable", se ) ; 
     resultList.clear (  ) ;   
  } finally  {  
     try  {  
         if  ( rs != null )   { rs.close (  ) ; rs = null; }  
         if  ( pstmt != null )   { pstmt.close (  ) ; pstmt = null; }  
         if  ( conn != null )   { DBUtil.closeDBConnection ( conn ) ; conn = null; }  
      }  catch  ( SQLException sqle )  {  }  
  } 


public boolean containsValue(Object value)
See Also:
V, HashMap, Map
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public V get(Object key)
See Also:
HashMap.put(Object, Object), Map
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LinkedHashMap()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1839]What is the main difference between HashMap and LinkedHashMap?
By Narayana P on 2006/10/30 14:47:31  Rate
LinkedHashMap class was added in J2SE1.4 and HashMap class was added in jdk1.2. and LinkedHashMap maintains the objects in the order they were added to the Map 
  
  
 Overall performance is best with the HashMap


public LinkedHashMap(int initialCapacity)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LinkedHashMap(int initialCapacity,
                     float loadFactor)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LinkedHashMap(int initialCapacity,
                     float loadFactor,
                     boolean accessOrder)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LinkedHashMap(Map<? extends K,? extends V> m)
See Also:
NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags