What is the Map interface?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the Map interface?

Rating:

Map is a generic interface of the Collections API defined as follows:

interface Map <key, value>

The Map interface defines a family of collection classes that map keys to values. There are generally no restrictions on the class of a key or the class of a value. Each key corresponds to a single value. A Map cannot contain duplicate keys. However, duplicate values are allowed.

The important methods of the Map interface are as follows:

  • put(key, value): This method is used to insert a value into a Map.
  • get(key): This method is used to obtain a value from a Map.
Methods in the Map interface throw the following exceptions:
  • ClassCastException: This exception is thrown when an object is incompatible with the elements of a Map.

  • NoSuchElementException: This exception is thrown when a Map is empty.

  • NullPointerException: This exception is thrown when an attempt is made to add a null value to the class that does not accept null.

  • UnSupportedOperationException: This exception is thrown when an attempt is made to modify an unmodifiable Map.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.