#
1. To convert arrays to list use Arrays.asList() methodnote
The type of array must be a Wrapper Class(Integer,FLoat, etc) in case of primitive data types(int,float,etc) , i.e you can’tpass int a[] but you can pass Integer a[]. If you pass int a[],this function will return a List <int a[]> and not List<Integer> , as “autoboxing” doesn’t happens in this case and int a[] is itself identified as an object and a List of intarray is returned, instead of list of integers , which will give error in various Collection functions
#
2. Initialize ArrayList#
3. Set - Set don't allow duplicate elements- Initialize
- Set is a unordered collection of unique data, data is stored and retrieved in random order.
- LinkedHashSet - ordered collection of set, data is stored and retrieved in the same order
- TreeSet (sorted Set) - all the elements are sorted in ascending order
#
4. Initialize Stack- Stack operations
- push() - push element to the stack
- pop() - pop top element from the stack and returns the element
- peek() - returns top element of the stack without removing
- isEmpty() - is used to check if a stack is empty or not, returns true/false
- push() - push element to the stack
#
5. Iterate a List (in A Loop)- First create a iterator for the list
- Iterate through list using hasNext() check condition, it returns boolean if the next element is present from the position of the iterator i
- Get the element of the list, returns the next element of the list until the hasNext condition fails