ArrayList in Java: Demo & Methods

preview_player
Показать описание
Java ArrayList: In this java ArrayList Demo video, we will have a look at what java ArrayList is and how ArrayListcan be implemented in Java programming l language. The utility methods ArrayList offers will give you a good idea of why we use ArrayList in java!

Best Hindi Videos For Learning Programming:

►C Language Complete Course In Hindi -

►JavaScript Complete Course In Hindi -

►Django Complete Course In Hindi -

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

L1.removeAll (l2) ~ used to remove all objects of l2 from l1
l1.removeIf (n-> (n% 5==0) ) ~ removes all elements from l1 if that element is divisible by 5

adhyakeshri
Автор

1) l1.subList(1, 3) --> This method is used to get elements from index 1 to 3 (excluding 3)

2) l1.retainAll(l2) --> This method removes all elements from l1 that are not present in l2. Hence, only common elements are retained.

amritachaudhari
Автор

18:54
Two methods for Array List

remove() -> takes the index of an element as an argument and then removes the element
clear() -> removes all the element from array list.

Thank You Harry bhaiya

thatcoolkid
Автор

Two additional methods of ArrayList <E> :
1. isEmpty() method -> returns true if the array is empty (has no elements)
2. remove() method -> removes the element at the specified position

vishwasbist
Автор

•subList(indexfirst, last index)
It return subList from starting_index to lastIndex-1, which is stored in another arraylist.
•toArray()
This method return the array which contains all the elements of arrayList
return object array
Thanks bhaiya

ashutoshranjan
Автор

l1.sublist(3, 6) -> This will return the value in the range of 3rd to 5th element which is stored in the array list
l1.trimToSize() -> This will trim the left part of your array-like if you have given the space of 500 but you only used 240 so it will automatically delete the remaining element which will save the time of program and memory

ayushsrivastava
Автор

trimToSize() ->trims the size of the array
removeRange(int fromIndex, int toIndex) ->remove elements between the given range

SHAIKSAMEERABEGUM-gr
Автор

removeRange(1, 5)- will remove elements from index 1 to 5
Removeif (condition)- it will check condition if condition satisfied, then it will remove that element.

sanketvidhate
Автор

1. Collections.sort(listname);
This method is used sort the list is ascending order.
2.l1.retainAll(l2);
this method will remove all values of l1 and will keep only l2 values


The first one is very helpful use it.

himanshusharma
Автор

1) .isEmpty -> This function returns Boolean value whether the List is empty or not.
2) .remove(int index) -> This function removes the element at a particular index.

arjunreddy
Автор

1) remove​(Object o) - removes the specified element from the list which appears for the first time in the list.
2) removeRange​(int fromIndex, int toIndex) - removes the elements within the specified limits from the list.

nupurdalvi
Автор

1.Collections.sort(l1) which helps to sort the ArrayList in ascending order and for descending order Collections.sort(l1, Collections.reverserOrder());
2.l1.replaceAll((n)->n+1); which helps to replace all the items in the list as an update

kanchansharma
Автор

1. subList(int fromIndex, int toIndex)
This function returns a portion of the array list from a specified index which is the fromIndex (inclusive) to a specified index which is toIndex (exclusive) . For example if the ArrayList l1 contains the following integer elements:- 788, 15, 18, 19, 1, 5, 6, 7, 4, 6, 676. The function l1.subList(2, 5) will return the output as [18, 19, 1].

2. retainAll( Collection<?> c)
This function returns all the elements of an arraylist which are a part of another arraylist.
Example:
l1 arraylist contains 1, 2, 3, 4 & l2 arraylist contains 1, 6, 7, 2 and then we are using the function l1.retainAll(l2) then l1 arraylist will retain only 1&2 elements. If we print l1 arraylist only 1 and 2 will be printed and if we print l2 arraylist then 1, 6, 7, 2 will be printed.

sumananath
Автор

IsEmpty() - checks whether the list is empty or not

Replaceall(collection<>)- replaces the list with the provided list

puneetshakya
Автор

Make a project in Java also as you made different projects in Python .

Mohit_Saini_YT
Автор

1) list_2) :- Removes all elements in list_2 from list_1
eg. if list_1={1, 3, 5, 6, 7} and list_2={1, 5, 6} then after this code list_1 will be = {3, 7}.

2) list_2) :- Retains all elements in list_1 that are in list_2 and removes all other eg. if list_1={1, 3, 5, 6, 7} and list_2={1, 5, 6} then after this code list_1 will be = {1, 5, 6}.
Thank you Harry Bhai!!

abhijeetkhare
Автор

Thanks sir for providing a free java did not even need to attend an extra class to learn java

achintyagupta
Автор

19:44 two methods are
✓get(index no) gives the element present at that number
✓isEmpty() checks whether the Array list is empty or not

chiragsharma
Автор

1. removeIf(): removes elements from the list which satisfy the given condition.
2. trimToSize(): to save space reduces the remaining size of the defined ArrayList .

donbrad
Автор

Harry Java ki series me Century ka liya advance me CONGRATULATIONS. 🥳🥳🎊🎉

HarshVardhan-bxpv
welcome to shbcf.ru