MAP

  1. If we want represent a group of objects as a key value pairs then we should go for Map interface.Both key and and value are objects only.
  2. Duplicate keys are not allowed but values can be duplicated.
  3. Map interface is not child interface of Collection.

سوق الاسهم السعودية التداول

تجارة الذهب في الكويت

HashMap

  1. The underlying data structure for HashMap is Hashtable.
  2. Duplicate keys are not allowed but values may be duplicated.
  3. Heterogeneous objects are allowed for both keys and values.
  4. null is valid for both key and value

مباشر الاسهم تداول Difference between HashMap and Hashtable

HashMap Hashtable
No method is synchronized in HashMap All methods are synchronized in Hashtable
HashMap object is not thread safe Hashtable object is not thread safe
null is allowed for both key and value null is not allowed for both key and value
HashMap is non-legacy class and introduced in 1.2v Hashtable is non-legacy class and introduced in 1.0v

سعر الذهب اليوم في السعوديه مرتفع او منخفض Constructors of HashMap

Construcor Description
HashMap hashMap=new HashMap() Creates an empty HashMap object with default initial capacity 16 and default fill ratio 0.75
HashMap hashMap=new HashMap(int initialCapacity)
HashMap hashMap=new HashMap(int initialCapacity,float fillratio)
HashMap hashMap=new HashMap(Map map)

http://www.bteq.es/?ratet=%D8%AA%D8%B9%D9%84%D9%8A%D9%85-%D8%B9%D9%84%D9%89-%D9%85%D8%A4%D8%B4%D8%B1%D8%A7%D8%AA-%D8%A7%D9%84%D8%A3%D8%B3%D9%87%D9%85&b20=79 تعليم على مؤشرات الأسهم Example:

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {

	public static void main(String[] args) {
		HashMap map = new HashMap();
		map.put("Gosling", 900);
		map.put("Davidson", 800);
		map.put("Bloch", 500);
		map.put("Mcclanahan", 700);
		System.out.println(map.put("Bloch", 678));
		System.out.println(map);
		// getting keys from HashMap
		Set set = map.keySet();
		System.out.println(set);
		// getting values from HashMap
		Collection collection = map.values();
		System.out.println(collection);
		// getting entries from HashMap
		Set entrySet = map.entrySet();
		Iterator iterator = entrySet.iterator();
		while (iterator.hasNext()) {
			Map.Entry mapEntry = (Map.Entry) iterator.next();
			System.out.println(mapEntry.getKey() + "--" + mapEntry.getValue());
			if (mapEntry.getKey().equals("Gosling")) {
				mapEntry.setValue(2000);
			}
		}
	}
}
/*
500
{Davidson=800, Mcclanahan=700, Bloch=678, Gosling=900}
[Davidson, Mcclanahan, Bloch, Gosling]
[800, 700, 678, 900]
Davidson--800
Mcclanahan--700
Bloch--678
Gosling--900
*/

LinkedHashMap

LinkedHashMap is a child class of HashMap and LinkedHashMap is exactly similar to the HashMap except the following differences.

HashMap LinkedHashMap
The underlying data structure is Hashtable The underlying data structure is a combination of Hashtable and LinkedList
insertion order is not preserved insertion order is preserved
introduced in 1.2v introduced in 1.4v

forex egp usd Example:


import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public class LinkedHashMapDemo {

	public static void main(String[] args) {
		LinkedHashMap map = new LinkedHashMap();
		map.put("Gosling", 900);
		map.put("Davidson", 800);
		map.put("Bloch", 500);
		map.put("Mcclanahan", 700);
		System.out.println(map.put("Bloch", 678));
		System.out.println(map);
		// getting keys from HashMap
		Set set = map.keySet();
		System.out.println(set);
		// getting values from HashMap
		Collection collection = map.values();
		System.out.println(collection);
		// getting entries from HashMap
		Set entrySet = map.entrySet();
		Iterator iterator = entrySet.iterator();
		while (iterator.hasNext()) {
			Map.Entry mapEntry = (Map.Entry) iterator.next();
			System.out.println(mapEntry.getKey() + "--" + mapEntry.getValue());
			if (mapEntry.getKey().equals("Gosling")) {
				mapEntry.setValue(2000);
			}
		}
	}
}
/*
Output
{Gosling=900, Davidson=800, Bloch=678, Mcclanahan=700}
[Gosling, Davidson, Bloch, Mcclanahan]
[900, 800, 678, 700]
Gosling--900
Davidson--800
Bloch--678
Mcclanahan--700
*/

http://nexxis.com.au/?afios=%D8%AA%D8%AD%D9%88%D9%8A%D9%84-%D8%A7%D9%84%D8%A7%D8%B3%D9%87%D9%85-%D9%85%D9%86-%D8%A8%D9%86%D9%83-%D8%A7%D9%84%D9%89-%D8%A8%D9%86%D9%83&0fb=f0 تحويل الاسهم من بنك الى بنك IdentityHashMap
In the case of HashMap to identify duplicate keys JVM always use .equals() method.
But in the case of IdentityHashMap instead of .equals() method JVM will use == operator to identify duplicate keys.

http://sacramentomountainsradioclub.org/?hifer=%D8%A7%D8%B3%D8%B9%D8%A7%D8%B1-%D8%B3%D9%88%D9%82-%D8%A7%D9%84%D8%B0%D9%87%D8%A8&238=5c اسعار سوق الذهب Example


import java.util.HashMap;
import java.util.IdentityHashMap;

public class IdentityHashMapDemo {

	public static void main(String[] args) {
		
		//HashMap implementation
		HashMap map=new HashMap();
		Integer i1=new Integer(100);
		Integer i2=new Integer(100);
		map.put(i1, "JAVA");
		map.put(i2, "PHP");
		System.out.println(map);
		//IdentityHashMap implementation
		IdentityHashMap identityHashMap=new IdentityHashMap();
		Integer i3=new Integer(100);
		Integer i4=new Integer(100);
		identityHashMap.put(i1, "JAVA");
		identityHashMap.put(i2, "PHP");
		System.out.println(identityHashMap);
	}
}
/*
Output
{100=PHP}
{100=JAVA, 100=PHP}
*/

http://www.receptikojevolim.com/?kyweitar=%D8%A8%D9%8A%D8%B9-%D8%A7%D8%B3%D9%87%D9%85-%D9%88%D8%B1%D8%A8%D9%87-%D8%B9%D9%86-%D8%B7%D8%B1%D9%8A%D9%82-%D8%A7%D9%84%D9%86%D8%AA&eea=88 بيع اسهم وربه عن طريق النت WeakHashMap

  1. In the case of HashMap an object is not eligible for garbage collector even though it doesn’t contain any external references if it is associated with HashMap.
  2. In the case of WeakHashMap an object is eligible for garbage collector if it doesn’t contain any external references even though it is associate with WeakHashMap.
  3. That is HashMap dominates the garbage collector where as garbage collector dominates the WeakHashMap.

http://holisticintegratedmedicine.com/suge-knights-self-defense-claims-might-be-valid-cle/ بنك الانماء الأسهم Example:


import java.util.HashMap;
import java.util.WeakHashMap;

public class WeakHashMapDemo {

	public static void main(String[] args)throws InterruptedException {
		//HashMap implementation.
		HashMap map=new HashMap();
		Demo d=new Demo();
		map.put(d, "JAVA");
		System.out.println(map);
		d=null;
		System.gc();
		Thread.sleep(5000);
		System.out.println(map);
		
		
		//WeakHashMap implementation.
		WeakHashMap weakHashMap=new WeakHashMap();
		Demo d1=new Demo();
		weakHashMap.put(d1, "JAVA");
		System.out.println(weakHashMap);
		d1=null;
		System.gc();
		Thread.sleep(5000);
		System.out.println(weakHashMap);
	}

}

class Demo{
	public String toString(){
		return "demo";
	}
	public void finalize(){
		System.out.println("Demo::finalize");
	}
}
/*Output:
{demo=JAVA}
{demo=JAVA}
{demo=JAVA}
Demo::finalize
{}
*/

http://holytrinityrandolph.com/?yriya=%D9%81%D9%88%D8%B1%D9%83%D8%B3-%D8%AA%D8%AC%D8%B1%D9%8A%D8%A8%D9%8A&ca5=72 فوركس تجريبي SortedMap
If we want arrange all entries according to some sorting order of keys then we should go for ‘SortedMap’.
SortedMap interface defines the following 6 specific methods.

  1. Object firstKey()
  2. Object lastKey()
  3. SortedMap headMap(Object key)
  4. SortedMap tailMap(Object key)
  5. SortedMap subMap(Object key1,Object key2)
  6. Comparator comparator()

TreeMap

  1. The underlying data structure is RED-BLACK tree.
  2. Duplicate keys are not allowed values can be duplicated.
  3. Insertion order is not preserved and it is based on sorting order of keys
  4. If we are depending on natural sorting order,The keys should be homogenous and comparable other wise we will get ClassCastException.
  5. If we are defining out own sorting by Comparator then keys can be heterogeneous need not be Comparable.
  6. There are no restrictions on values these can be heterogeneous.

http://littleredgoblingames.com/?kompot=%D8%B3%D8%B9%D8%B1-%D8%A7%D9%84%D8%B0%D9%87%D8%A8-%D8%A7%D9%84%D9%8A%D9%88%D9%85-%D9%81%D9%8A-%D8%A7%D9%84%D9%83%D9%88%D9%8A%D8%AA سعر الذهب اليوم في الكويت null insertion in TreeMap

  1. If we are trying to insert null value in non empty TreeMap we will get NullPointerException.
  2. For the empty TreeMap as the first entry with null key is allowed.But after inserting that entry if we are trying to insert any other entry we will get NullPointerException.
  3. For the values no restrictions ,We can use any number of nulls.

موعد تداول أسهم شركة الجزيرة تكافل تعاوني Constructors:

Constructor Description
TreeMap map=new TreeMap() It is used for natural sorting order.
TreeMap map=new TreeMap(Comparator) It is used for customized sorting order.
TreeMap map=new TreeMap(Map)
TreeMap map=new TreeMap(SortedMap)

مباشر سوق الأسهم السعودية اليوم Example:Natural sorting order


import java.util.TreeMap;

public class TreeMapDemo {

	public static void main(String[] args) {
		TreeMap map=new TreeMap();
		map.put("Gosling",1000);
		map.put("Davidson",2000);
		map.put("Mcclanahan",500);
		map.put("Bloch",null);
		//map.put(890,"James");//java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer.
		//map.put(null,"JAVA");//java.lang.NullPointerException
		System.out.println(map);
		}
}
/*
Output:
{Bloch=null, Davidson=2000, Gosling=1000, Mcclanahan=500}
*/

http://www.inehd.org/?rupx=%D8%AA%D8%AF%D8%A7%D9%88%D9%84-%D8%A7%D8%B3%D9%87%D9%85-%D9%88%D9%87%D9%85%D9%8A&c91=e1 تداول اسهم وهمي Example:Customized sorting order.


import java.util.Comparator;
import java.util.TreeMap;

public class TreeMapDemo {

	public static void main(String[] args) {
		TreeMap map=new TreeMap(new ComaratorDemo());
		map.put("Gosling",1000);
		map.put("Davidson",2000);
		map.put("Mcclanahan",500);
		map.put("Bloch",null);
		System.out.println(map);
		}
}

class ComaratorDemo implements Comparator{
	
	public int compare(Object obj1,Object obj2){
		String s1=(String)obj1;
		String s2=(String)obj2;
		return s2.compareTo(s1);
	}
}
/*Output:
{Mcclanahan=500, Gosling=1000, Davidson=2000, Bloch=null}
*/