Skip to main content

Posts

Showing posts from August, 2015

LinkedList in Java

/* LinkedList is a linked list implementation of the List interface.  * Implements all optional list operations, and permits all elements (including null).  * In addition to implementing the List interface, the LinkedList class provides uniformly named methods to get,  * remove and insert an element at the beginning and end of the list.  * These operations allow linked lists to be used as a stack, queue, or double-ended queue.  */ package collection.list; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; public class LinkedListDemo {     public LinkedListDemo() {         super();     }         public static void main(String[] args){ /* Linked list simple example  * LinkedList of type String */         simpleLinkedList(); /* LinkedList emaple with Employee class objects  * with sorting, iterating in forward and backword direction  */         LinkedList<Employee> employee = employeeLinkedList()

Vector in Java

/* The Vector class implements a growable array of objects.  * Like an array, it contains components that can be accessed using an integer index.  * However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.  */ package collection.list; import java.util.Collection; import java.util.Collections; import java.util.Vector; public class VectorDemo {     public VectorDemo() {         super();     }         public static void main(String []Args){ /*  * vector containing Integers  */         simpleVector(); /*  * vector containing objects of class Student  */        Vector<Student> students=vectorOfStudents();           }         public static void simpleVector(){         Vector<Integer> vector= new Vector<Integer>();         vector.add(1);         vector.add(21);         vector.add(113);         vector.add(14);         vector.add(51);         vector.add(67);    

ArrayList in java

/*  * Java ArrayList class uses a dynamic array for storing the elements.It extends AbstractList class and implements List interface.  * Can contain duplicate elements.  * Maintains insertion order.  * Non synchronized.  * Allows random access because array works at the index basis.  * Manipulation is slow because a lot of shifting needs to be occurred if any element is removed from the array list. */ package collection.list; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; public class ArrayListDemo {     public ArrayListDemo() {         super();     }         public static void main(String args []){         /*  * creating old non-generic arraylist  */         ArrayList al=new ArrayList();         /*  * ArrayList with normal data or objects of int,string etc (generic arraylist ) */         simpleArrayCheck(); /*  * ArrayList of objects of employee class and uses Comparable interface for sortin

List interface in java

List Interface : A List interface is about the index . The one thing that List has that non-lists don't have is a set of methods related to the index. Those key methods are like get(int index), indexOf(Object o), add(int index, Object obj), and so on. All three List implementations are ordered by index position. position that you determine either by setting an object at a specific index or by adding it without specifying position.The three List implementations are.      ArrayList      Vector      LinkedList Some key points about these implementation classes are Refer below links for above classes examples. 1.  Array List implementation 2.  Vector Implementation 3.  LinkedList Implementation

Session Timeout

HTTP is a stateless protocol, the server receives no implicit notice that a client has closed his browser or it is idle. Therefore any Java EE-compliant server provides a standard, configurable session timeout mechanism to allow resources tied to the HTTP session to be freed when the user has stopped performing requests. We have to timeout mechanisams. 1. Implicit Timeout Due to User Inactivity and 2. Explicit HttpSession Timeout 1. Configure the Implicit Timeout Due to User Inactivity : You configure the session timeout threshold using the session-timeout tag in the web.xml file. The default value is 35 minutes. When the HttpSession times out the BindingContext goes out of scope, and along with it, any data controls that might have referenced application modules released to the pool in the managed state level. The application module pool resets any of these referenced application modules and marks the instances unreferenced again. 2. Explicit HttpSession Timeout  : To en