4:37 pm - Saturday September 23, 2017

Tag Archives: Collections

Collections Example program for indexOfSubList(List source, List target)

/** @description:Collections Example program for indexOfSubList(List Source, List target) @author:candidjava.com */ import java.util.List; import java.util.Collections; import java.util.Arrays; public class CollectionsIndexOfSubList...

Hashtable Example program for containsKey(Object key)

/** *@author:kingsley *@description:Hashtable Example program for ContainsKey */ import java.util.Hashtable; class HashTableExam { public static void main ( String[] args ) { Hashtable ht=new Hashtable(); // creating...

LinkedList Example Program for set(int index, E element)

//LinkedList Example Program for set(int index, E element) /** * @author   candidjava.com * @description: Replaces the element at the specified position in this list with the specified            element. */ import...

LinkedList Example Program for removeLast()

//LinkedList Example Program for removeLast() /** * @author   candidjava.com * @description: //Removes and returns the last element from this list. */ import java.util.LinkedList; public class List1 { public static void main(String...

LinkedList Example Program for removeFirst()

/** *LinkedList Example Program for removeFirst() * @author   candidjava.com * @description:  Removes first element of the linkedlist . */ import java.util.LinkedList; public class List { public static void main(String args[])...

LinkedList Example Program for remove()

/** *@author:candidjava *@description:LinkedList Example Program for remove() **/ import java.util.LinkedList; public class Remove { public static void main(String[] args) { // create a LinkedList LinkedList list = new LinkedList(); ...

LinkedList Example Program for pollFirst()

/** *@author: candidjava.com *@description: coding  for linked list poll method */ import java.util.LinkedList; public class LinkedListDemo { public static void main(String[] args) { // create a LinkedList LinkedList list =...

LinkedList Example Program for poll()

/*Remove and retrieve the head of the list using poll() and class Poll*/ /** *@Author: candidjava.com *@Description: Remove and retrieve the head of the list using poll() and class Poll */ import java.util.*; public class LinkedListPoll...

Vector Example Program for addAll(Collection c)

/** @author:candidjava.com @description:Vector example program for addAll(Collection c) */ import java.util.Vector; public class AddAll { public static void main(String args[]) { // create two objects of the vector Vector<Integer>...

Vector Example Program for addAll(int index, Collection c)

/*Program Name: Vector Example Program for addAll(int index, Collection c)*/ /** *@Author: Candidjava.com *@Description:Vector Example Program for addAll(int index, Collection c) Method is used to Inserts all of the elements in the...

Stack Example Program for retainAll(Collection c)

/** @author:candidjava.com @description:Stack example program for retainAll(Collection C) */ import java.util.Stack; public class StackRetainAll { public static void main(String[] args) { Stack s1 = new Stack(); // creating...

Stack Example Program for removeAll(Collection c)

/** *Stack Example Program for removeAll(Collection c) * @author candidjava.com * @description:Removes from this list all of its elements that are contained in the specified collection. */ import java.util.*; public class Line1...

Stack Example Program for containsAll(collection)

//Stack Example Program for containsAll(Collection c) /** * @author   candidjava.com * @Returns true if this list contains all of the elements of the specified collection. */ import java.util.*; public class Stac { public...

Stack Example Program for clone()

/** *@author:candidjava.com *@description:Stack example program for clone() */ import java.util.Stack; public class StackClone { public static void main(String[] args) { Stack s1 = new Stack(); // creating first stack for...

Spring Collection list Example Program in Eclipse

Project Structure: Jar Files: How to Add Jar Files:    spring-config.xml       <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean...

Hibernate Collection mapping array Using Eclipse

Array: <array name=”arrayName” table=”tableName” cascade=”all”> <key column=”anyColumnName” /> <list-index column=”anyColumnName” base=”1″> </list-index> ...

Hibernate Collection mapping Map Using Eclipse

Project Structure:                 JAR Files:                     MainClass.java: package com.candidjava; import java.io.DataInputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import...

Hibernate collection mapping List Using Eclipse

List: List can contain duplicates. <list name=”listName” table=”tableName” cascade=”all”> <key column=”anyColumnName”></key> <list-index column=”anyColumnName”> ...

Vector Example program to append all elements of other Collection using addAll()

/** *@author :CandidJava.com *@descriptions : This program explain the function and use of addAll() method */ import java.util.Vector; import java.util.ArrayList; class AppendAllElementsOfOtherCollectionToVector { public static...

Hashtable example program for Get() Collection values

/** *@author :CandidJava.com *@descriptions : This program explain to get the collection of values from Hashtable */ import java.util.Enumeration; import java.util.Iterator; import java.util.Hashtable; import java.util.Collection; class...