Skip to main content

HashMap in Java

    -What is HashMap:

      A HashMap has value and  key. store value based on Key. HasMap implements the Map interface and extends AbstractMap class.
      Allow only one null as key and can contain   multiple null value.
      Also Conatin Order of element.


        HasMap----extend---->AbstractMap----implement---->Map
       
        Now we see how to Put and Retrive value from HashMap.
       
       Example.

            import java.util.*;
              class MapTest{
                       public static void main(String args[]){
 
  HashMap<Integer,String> map=new HashMap<Integer,String>();
 
  map.put(1,"vjp");
  map.put(13,"Vasant");
  map.put(10,"anil");
 
  for(Map.Entry m:map.entrySet()){
  System.out.println(m.getKey()+" "+m.getValue());
  }
  }
}

 

        -How Internally Working.

     Example.







Comments

Post a Comment

Popular posts from this blog

Java 8 installation

Java 8 installation setup:       First of all ,we need to install java 8 jdk in your  machine.so for that you can download  it from following  url. click here download  jdk 1.8.0_11 and install it on your machine. Once installation has been done. Please checkout version of jdk. C:\Users\hp>java -version java version "1.8.0_11" Java(TM) SE Runtime Environment (build 1.8.0_11-b12) Java HotSpot(TM) Client VM (build 25.11-b03, mixed mode, sharing) once you have installed Java on your machine, you would need to set environment variables to point to correct installation directories                                                       ...

Java OOP Concepts

Java OOP Concepts Java OOP Concepts:       Java is not fully Object Oriented Programing Languages Because java Provide Primitive Data types Like int,string etc.             Java Provide Following OOPS: Object Class  Inheritance  Polymorphism Abstraction  Encapsulation 1.Object    -Object is nothing but just Blueprint Of Class Means it contain Properties And Behaviour Of Class.     example: real time Example is People, pen. 2.Class   -Class Contain Methods and Properties. so we can say that Collection of Object is nothing But Class. 3.Inheritance   -Inheritance is Process  or Scenario  for accessing Parent class Properties .Means access Properties and Method of Parent class into Sub Class. 4.Polymorphism    -In simple Word Polymorphism is way to Perform one Task in Multiple Dif...