Map interface

Map interface

What is the Map interface?
View Answers

October 19, 2010 at 5:40 PM

Hi,

Here is the answer.

The java.util.Map interface represents a mapping between a key and a value. The Map interface is not a subtype of the Collection interface. Therefore it behaves a bit different from the rest of the collection types. the interface starts of it?s own interface hierarchy, for maintaining key-value associations.

The interface describes a mapping from keys to values, without duplicate keys, by definition. The Map interface provides three collection views, which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map's collection views return their elements.

Thanks.


October 5, 2012 at 1:52 PM

The Map interface maps unique keys to values. A key is an object that you use to retrieve a value at a later date.

Given a key and a value, you can store the value in a Map object. After the value is stored, you can retrieve it by using its key.

Several methods throw a NoSuchElementException when no items exist in the invoking map.

A ClassCastException is thrown when an object is incompatible with the elements in a map.

A ClassCastException is thrown when an object is incompatible with the elements in a map.

A NullPointerException is thrown if an attempt is made to use a null object and null is not allowed in the map.

An UnsupportedOperationException is thrown when an attempt is made to change an unmodifiable map









Related Tutorials/Questions & Answers:
Map interface
Map interface  What is the Map interface
Introduction to Map and SortedMap Interface
Introduction to Map and SortedMap Interface       Map Interface: A Map... rather it has own interface hierarchy. Map provides a more general way
Advertisements
Map
Map  If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map either iterator or for each loop or for loop
map
map  using map, i want display message based on id selected [both are strings]   i do no   Hi Friend, Try the following code...) { Map map=new HashMap(); map.put("Message1","Hello
interface
interface   what is the use of marking interface
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
interface
interface  will the interface implements a interface   Hi Friend, No. Interface can extends another interface but cannot implements it, because interface will not contain the implementation. Thanks
INTERFACE
INTERFACE  how interface support multiple inheritance in java
interface
interface   Hi I have interface in that interface 3 methods are there , after some days client said that,i want to add one more method in that interface ,so how can add 4 method so that the implemented class did not affect
Java Map Iterate
Map is an Interface in the Collection Framework. Map is implemented by its two sub classes HashMap Treemap Map has no iterator method. So use the entrySet() method.It returns the data as Set Example of Java Map
interface
interface  can we extend interface?   Hi Friend, Yes an interface can be extended by other interface like using extends keyword interface A{ } interface B extends A{ } For Example: interface IntefaceA { void
interface
interface  what the use of interface?   An interface is one... variables.Any class can implement(inherit)the interface and make use... is achieved by using the interface (by implementing more than one interface at a time
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
Interface
for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance   An interface is one which has abstract... implement(inherit)the interface and make use of the methods(functions
interface
interface  why do we need interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need interface...THis is question often i heard from my developer
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  What is the exact use of interface in real time scenario? some people says that interface provides multiple inheritance. Is it true...; Through interface, we can achieve the multiple inheritance. Java does
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  Declare an Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class (1)Bungalow&(2)Flat both the lasses have following
Java Map iterator with example
Java Map Iterator is an interface. It keeps the data in the key and value form. It is implemented by HashMap, Tree Map. Map has no iterator method. So...() method to get the data in Set object form. Java Map Iterator with Example
Java Map Example
Map Interface adds keys to values. Every key in the Map Interface should be unique. It is part of java.util package. Each element in a map has a key... HashMap is used to implement Map Interface . put() method is used to add elements
Map.Entry Java Interface
Map.Entry Java Interface Sometimes you need to work with map entry. This can be done using Map.Entry Interface of Java. The Map interface's entrySet( ) method returns a set of map . These sets are called as Map.Entry object
Java Map Example
Java Map Example  How we can use Map in java collection?   The Map interface maps unique keys to value means it associate value to unique... Description:- The above example demonstrates you the Map interface. Since Map
What is an interface?
What is an interface?  What is an interface
Java Map
is not an extension of the collection interface rather it has own interface hierarchy. Map... classes that implement the Map interface: TreeMap, HashMap... Java Map        
Hash Map
Hash Map  how to add the hash map objects in the list and iterate the objects
Can an Interface implement another Interface?
Can an Interface implement another Interface?   Hi, Can an Interface implement another Interface? Thanks
Can an Interface extend another Interface?
Can an Interface extend another Interface?   Hi, Can an Interface extend another Interface? thanks
ServletRequest interface
ServletRequest interface   What is new in ServletRequest interface
Interactive map
Interactive map  hi........ i require map to be zoom in and enlarge the area and show its detail. Can anyone tel me how can this be done using java swings .... plz help
Map code
Map code  hi................ I have map of navi mumbai, where i want to see the location vashi, nerul, turbhe.... means want to zoom into this area and then again zoom in and see nerul location more properly or other location
Java interface
Java interface  What is the List interface
List interface
List interface  What is the List interface
hash map
hash map  write a program in hash map , that shows the value in asending order. but not key value. ex: key value ==== ===== k5 ashutosh k1 babita k7 debasis k2 vikas plz help me
Interface implimentation
Interface implimentation  How to impliment an interface For Achieveing MVC & loosCupling in Any Project
callable interface
callable interface  When we use the callable interface instated of runable interface
Java Interface
Java Interface  Can an Interface have an inner class?  Yes, interface can have inner class. for example- public interface gyan { static...("in interface"); }; public static void main(String args
Java interface
Java interface  What must a class do to implement an interface?  It must provide all of the methods in the interface and identify the interface in its implements clause
logfile interface
logfile interface  How to create logfile interface for programs in java
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
Java interface
Java interface  What modifiers may be used with an interface declaration
Marker interface
Marker interface  what is a marker interface? what is its significance
null interface
null interface   what is the null interface and what is the use of it in real java project ?   Hi Friend, A null interface is an interface without any methods.Is also known as Marker interface. Null interfaces are used
Map
marked interface
marked interface  how jvm work with marked interface?(that means how it will know its behaviour with out any methods)   Hi, Learn it at Market Interface in Java tutorial page.ADS_TO_REPLACE_1 Thanks
interface_querry
interface_querry  By using interface we have to implement all unimplemented methods into our class, even though we are not using all of methods, what is the alternative
Interface in java
Interface in java  An Interface method implemented in more than one different class with same method name. To avoid overriding of methods, we use ObjectReference for that class

Ads