5:47 am - Thursday August 17, 2017

Archive: Java Examples Subscribe to Java Examples

LinkedHashMap example programs and Tutorial in java

BACK 1.Fetch all keys from a LinkedHashMap Set<K> keySet() 2.Clear all elements from LinkedHashMap void Clear() 3.Retrieve value of given Key in LinkedHashMap V get(Object key) 4Check whether a given key is available in LinkedHashMap...

Add Object to specific index of an ArrayList boolean add(int index,E element)

BACK                             This method is used to add object at specified index position in an arraylist and this method will return true if the Object is successfully added.. Example Program import java.util.ArrayList; public...

Add object to an ArrayList boolean add(E e)

BACK                           An array is used to store the collection of data. add( ) method is used to add element in the list to store the data. Example Program import java.util.ArrayList; public class Fun...

Add all object from another Collection boolean addAll(collectionc)

BACK                                 This method is used to add All object to ArrayList from another Collection Objects. Example Program import java.util.ArrayList; public class Fun { public static...

Retrieve the last index position of an object int lastIndexOf(Object o)

BACK                                          This method returns the index value of the last occurrence of the specified element in the list. This method returns negative value if the specified element...

Retrieve the first index position of an object int indexOf(Object o)

BACK                                         This method returns the index value of the first occurrence of the specified element in the list. This method returns negative value if the specified element...

Check whether a given ArrayList is Empty boolean isEmpty()

BACK                              This method is used to check whether the given list is empty or not. If the list contains no element then the boolean result is true or else it returns false.  Example Program import...

Retrieve object from an index position Object get(int index)

BACK                               This method returns the specified element in the array list based on the index value. Example Program import java.util.ArrayList; public class Get { public static void...

Check whether an object is present in ArrayList boolean Contains(Object o)

BACK                                 This method is used to check whether the specified element is present in the list or not. It returns boolean result(i.e true or false) based on the specified element. Example...

Retrieve all Keys from HashMap to Set – Set keySet()

BACK                                      This function returns a  set view of the keys contained in the map. Example Program import java.util.HashMap; import java.util.Set; public class Key { ...

Clear all values from the hashMap void clear()

BACK                      This method is used to remove all of the mappings from this map. It removes all the key and values that are all created in a specified map. Example Program import java.util.HashMap; import...

Check whether the value is available in HashMap boolean containsValue(Object value)

BACK                       This function returns true if this map maps more than one keys to the given value. Example Program import java.util.HashMap; public class Containsvalue { public static void main(String args[]) { HashMap...

Check whether the value is available in HashMap boolean containsValue(Object value)

BACK                   This function returns a  set view of the keys contained in the map. Example Program import java.util.HashMap; public class Containsvalue { public static void main(String args[]) { HashMap...

ArrayList example programs and Tutorial in java

BACK .   1.Check whether an object is present in ArrayList boolean Contains(Object o)     2.Retrieve object from an index position Object get(int index)     3.Check whether a given ArrayList is Empty boolean isEmpty()     4.Retrieve...

Sample programs in Jsp

Auto Refresh example Using Jsp Image Viewer example Jsp File Download example Using Jsp File Upload example Using Jsp Find no of Hits example  Using Jsp Login Page example Using Jsp Sample Registration Form example Using Jsp

Check whether the key is available in HashMap boolean containsKey(Object key)

BACK                                   This function returns true if the map contains  mapping of the given  key. Example Program import java.util.HashMap; public class Hash { public static void...

Change the HashMap to Collection (value) Collection values()

 BACK                          This method is used to return a collection view of the values contained in the hash map. Retrives all Values from the hashMap and add them in a Collection Object. Example program import...

Check whether the HashMap is empty boolean isEmpty( )

BACK                                This method is used to check whether the map contains key-value mappings or not. If there is no mappings (i.e empty), it returns true or else it returns false. If the hashMap...

Remove a value from HashMap by its key using remove(Object key )

BACK                      This method is used to remove the mapping for the specified key and if the specified key is not available it returns null. Example Program import java.util.HashMap; public class Hash2 { public...

Creating a clone(duplicate) of HashMap using Object clone

BACK                    This function is used to provide a copy of an object of a class and it implements cloneable interface. Copies the objects and its content to it new variable. Example Program import java.util.HashMap; import...