Tuesday, January 5, 2010

How to get a Text box using java script?

prompt() is used to get the text box.

Example:

prompt("Enter your name :");

How to get a Text box using java script?

How to give Alert/Messsge box in JavaScript?

alert('your message to be popped up');

Example:
< input type="button" value="Example" onclick="alert('your message to be popped up');return true" />

If you open this code with the Browser then you can see a button named with "Example".
If you click on it it will popup a message box with the message 'your message to be popped up'.

Friday, August 22, 2008

Differences: HashTable Vs HashMap

HashTable Vs HashMap
  • Hashtable is synchronized and thread-safe.HashMap is asynchronized and faster.
  • HashMap implements Map interface.By using the Map interface it can switched between TreeMap &HashMap.
  • HashMap permits the null values as key or value but Hashtable does not.
  • HashMap does not guaranteed to store the values in a constant order over a period of time.
  • Synchronization can be achieved by the HashMap by using java.util.collections.synchronizedMap(yourHashMap).This feature is added in JDK1.5.


When to go What?

  • Is your operation is multithreaded ?: HashTable(less than jdk1.5).
  • Is the datatype of key is Integer ? : HashTable has better performance if the data type of the key is Integer.

Thursday, August 21, 2008

Difference between Arraylist Vs Vector

Arraylist Vs Vector


  • Vector is synchronous but arraylist is asynchronous.
  • Vector & Hashtables are introduced in JDK1.0 but Araaylist & HashMaps are introduced in JDK1.2.
  • vector is comparatively slow with Arrraylist.

When to use what?

  • If your data is accessed by multiple threads then go for Vector.
  • If your list is a local variable then go for Arraylist blindly.
  • If your data is accessed by a single thread then go for Arraylist.