java left logo
java middle logo
java right logo
 

Home arrow Java SE Tips arrow java.util arrow How to extend LinkedHashMap
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4091
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to extend LinkedHashMap E-mail
User Rating: / 17
PoorBest 

This sample code will shows the use of LinkedHashMap. The class LinkedHashMap extends teh LinkedHashMap and overrides its removeEldestEntry() method. This method will set the maximum number of elements in the map to 10. If an element is added to the map after this capacity, one element gets deleted which was added very first.

import java.util.LinkedHashMap;
import java.util.Map.Entry;

public class LnkdHshMap extends LinkedHashMap {

    private static final long serialVersionUID = 1L;

    protected boolean removeEldestEntry(Entry arg0) {
        return size() 10;
    }
}

 Related Tips

 
< Prev   Next >
 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.