ArrayList in Java: Demo & Methods

Поделиться
HTML-код
  • Опубликовано: 7 янв 2025

Комментарии •

  • @thatcoolkid370
    @thatcoolkid370 3 года назад +39

    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

  • @amritachaudhari6473
    @amritachaudhari6473 Год назад +125

    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.

    • @Anushka20037
      @Anushka20037 Год назад

      notes???

    • @singhkxtmanjot8393
      @singhkxtmanjot8393 7 месяцев назад +2

      Wow! Great thanks for sharing these are new for me

    • @saurabhrana2534
      @saurabhrana2534 5 месяцев назад +1

      extending second example:
      what if we want to remove element which are common(opposite of retainAll)
      we will use l1.removeAll(l2)
      say l1=[1,2,3]
      l2=[3,4,5]
      then output will be [1,2]

    • @AyelaAhsan-r5u
      @AyelaAhsan-r5u 3 месяца назад +1

      L1.clear();
      Used to clear the array
      L1.set(2,555);
      Replace or store the element 555 in 2nd index of array

    • @biswajeet9826
      @biswajeet9826 3 месяца назад

      like intersection!

  • @adhyakeshri355
    @adhyakeshri355 3 года назад +202

    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

  • @vishwasbist1974
    @vishwasbist1974 3 года назад +40

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

    • @sejankhan
      @sejankhan 2 года назад +1

      can you please give the link of those methods?

  • @ashutoshranjan4644
    @ashutoshranjan4644 3 года назад +49

    •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

    • @Roby_99
      @Roby_99 3 года назад +1

      removeRange( int starting index, last index) -->>> this removes elements in the arraylist. Starting index included and last index excluded..
      *** This method has protected access...***

    • @arshsethi8596
      @arshsethi8596 3 года назад

      ye bhi batate ki sublist ko try catch mei wrap krna padta hai use krne keliye for indexoutofbound exception and illegalargumentexception

  • @ayushsrivastava1095
    @ayushsrivastava1095 3 года назад +28

    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

  • @abhijeetkhare7815
    @abhijeetkhare7815 3 года назад +6

    1) list_1.removeAll(collection 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_1.retainAll(collection 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!!

  • @himanshusharma2335
    @himanshusharma2335 Год назад +6

    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.

  • @SHAIKSAMEERABEGUM-g1r
    @SHAIKSAMEERABEGUM-g1r 2 дня назад +1

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

  • @nupurdalvi5238
    @nupurdalvi5238 3 года назад +34

    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.

  • @achintyagupta1991
    @achintyagupta1991 9 месяцев назад +1

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

  • @sumananath4472
    @sumananath4472 3 года назад +1

    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.

  • @arjunreddy7013
    @arjunreddy7013 2 года назад +15

    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.

  • @sanketvidhate7650
    @sanketvidhate7650 4 года назад +33

    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.

  • @kanchansharma9692
    @kanchansharma9692 6 месяцев назад +2

    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

  • @donbrad5079
    @donbrad5079 6 месяцев назад +2

    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 .

  • @balboa7
    @balboa7 2 года назад +5

    18:54
    1. trimToSize(): This method is used to minimize the storage of Arraylist to its current size
    2. clone(): It mainly returns a copy of the arraylist
    - Shivam

  • @Saurav1-d4f
    @Saurav1-d4f Год назад +1

    from Hello world to arraylist is the sign of consistency thank you harry saab!.

  • @Mohit_Saini_YT
    @Mohit_Saini_YT 4 года назад +127

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

  • @raahulsuman4922
    @raahulsuman4922 2 года назад

    1.remove​(Object o) Method ke throw hum Array list ke koi bhi element ko remove kr sakte he.
    2.clone():-clone method ko throw hum koi bhi list ka clone kr sakte he
    Thank you Herry Bhai for this Confidence

  • @sriharivernekar2255
    @sriharivernekar2255 Год назад

    Methods I found are :
    1) .clone() ----> This methods will give you a duplicate copy of the arrayList.
    2) .sort(Comparator c) ----> This method will arrange your data or elements of an arraylist in ascending order. You can even put a custom Comparator for arranging your elements differently.
    Harry Bhai you have and are doing a great job. Thank you so much.

  • @chiragsharma7022
    @chiragsharma7022 3 года назад +6

    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

  • @puneetshakya3001
    @puneetshakya3001 4 года назад +12

    IsEmpty() - checks whether the list is empty or not
    Replaceall(collection)- replaces the list with the provided list

  • @kpurnachandrapavan845
    @kpurnachandrapavan845 Год назад +1

    Thank You Harry Bhai 😊
    toArray() :
    This method will return an array containing all the elements in our ArrayList .
    Suppose our ArrayList is arr1 . To convert our ArrayList to an array we will do the following ->
    Code :
    int[] newArr = arr1.toArray();

  • @ahmad.sln.4
    @ahmad.sln.4 3 месяца назад +1

    equals(Object o) :- Compares the specified object with this list for equality.
    get(int index) :- Returns the element at the specified position in this list.

  • @Sunil2024-n9h
    @Sunil2024-n9h 18 дней назад +1

    Two methods of ArrayList
    1. isEmpty() :- Use to check whether the Arraylist is empty or not.
    2. equal() :- Use to compare two ArrayList.

  • @krishnawadhwani5393
    @krishnawadhwani5393 4 года назад +5

    Best RUclips Channel In This Universe Even Aliens Agree To It, Thank You For This Much Great Content, Harry Sir

  • @SurajKumar-hd1gz
    @SurajKumar-hd1gz 11 месяцев назад +1

    1. remove (object k) : isme jo bhi index denge us index ki value remove ho jayegi
    2. clone() : is method se ArrayList ka ek clone ya dublicate ArrayList ban jayega

  • @manishdubey4772
    @manishdubey4772 2 года назад +1

    isEmpty() - It is type of method used to check that whether the arrayList contain some element or not .If it contain some element in it it means it will return 'true' otherwise 'false' .
    equals(Object o) - It is type of method used to check two array i.e whether the both are are equal or not if it is then it will return 'true' otherwise 'false' .

  • @12_parthgarware50
    @12_parthgarware50 Год назад

    toArray - public T[] toArray(T[] a)
    Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.
    If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)

  • @HarshVardhan-bx4pv
    @HarshVardhan-bx4pv 4 года назад +13

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

  • @thatonichan
    @thatonichan 3 года назад

    retainAll(Collection c)
    Retains only the elements in this list that are contained in the specified collection.
    toArray()
    Returns an array containing all of the elements in this list in proper sequence (from first to last element).

  • @uday4245
    @uday4245 Год назад

    1] l1 .subList(int a,int b) -> Prints element of array l1 from index a to index b (a is included and b in excluded)
    2] l1.hashCode() -> provides the hashcode value of the arrayList

  • @RAJATDHIMAN-t4r
    @RAJATDHIMAN-t4r Год назад +1

    1) Cloneing the L1,L2 list -->
    Object l3 = l1.clone(); // Clone the object
    for (Integer res : (ArrayList) l3) {
    System.out.println(res);
    }
    2. Ensure capacity of list-->
    l2.ensureCapacity(10);

  • @aashutoshkumar8597
    @aashutoshkumar8597 2 года назад +1

    trimToSize( )==> Trims the capacity of the array list.
    toArray( )==> Returns an Array containing all the elements from first to last.

  • @ankushsingh1977
    @ankushsingh1977 2 года назад

    Work Done.
    If we to check our array list is empty or not we can use isEmpty() method
    boolean a = l1.isEmpty();
    System.out.println(a);
    // Returns a specific portion of our array while using subList(int fromIndex, int toIndex) method
    List x = l1.subList(1,4);
    System.out.println(x);

  • @RishitaTomar-ku8ob
    @RishitaTomar-ku8ob Год назад +1

    Two methods
    1.Clone()- return a copy of the list.
    2.equal()- this method compare the size of the two array List.
    👍

  • @dhairyaoza5422
    @dhairyaoza5422 3 года назад +3

    toArray() - Returns an array containing all of the elements in this list in proper sequence (from first to last element).
    trimToSize() - Trims the capacity of this ArrayList instance to be the list's current size.

  • @harshmishra2288
    @harshmishra2288 Месяц назад +1

    1) l1.retainAll(l2) --> Only common elements are left in the l1 list
    2)l1.remove(n)--> Removes the nth index of the list

  • @avishekYT
    @avishekYT 3 года назад +8

    Isempty() and toArray() the first one returns a boolean expression like if the arraylist is empty it returns true, and the second one is for printing the array in sequence from first to last.

  • @Antriksh-m2s
    @Antriksh-m2s Год назад

    1. .isEmpty() --> to check if the list is empty or not will throw a boolean
    2. .remove() -> if you specify the index inside the parenthesis the list will remove the obj from that particular index in the list
    Thank you harry love you

  • @theDivyanshuSrivastava
    @theDivyanshuSrivastava 10 месяцев назад

    l1.hashCode() --> It will give us the hashCode value for the specific list. It is calculated based on the individual element's hash Value.
    l1.removeRange(int from , int to) --> It will remove the elements starting 'from' till the 'to'' index

  • @GopiKishanSahu-u6k
    @GopiKishanSahu-u6k 10 дней назад +1

    removeRange(int fromIndex ,int toIndex);
    Iss method mei hum apne collection se particularly from index aur usko milakar se lekar to index exclusive thak apne array se remove karte hai.
    isEmpty();
    yeh ek Boolean hai jo ki return true karega agar array mei koi element nhi hoga nhi toh false dega.

  • @AnandMishra-rn4tp
    @AnandMishra-rn4tp 5 месяцев назад

    1 - sout(l1.isEmpty()); - false
    2- sout(l1.iterator()); - Java.util.ArrayList$List@Itr@6acbcfc0
    3 - sout(l.remove(index:7)); - 6
    4- sout (l.remove(index:4)): - 6
    20:07

  • @nishanth4177
    @nishanth4177 3 года назад +5

    *L1.remove(any integer you have given):-it removes the element from the array
    *Sout(l1.clone());->prints a copy of integers you have given in l1
    *Sout(subList(2,3)):-> prints the integers from index 2 to 3 in array
    *l1.clear()->removes all integers of l1

    • @vittalprabhu379
      @vittalprabhu379 Год назад

      it does not remove integer given.. it removes the integer at that index

  • @ninjaworriar8964
    @ninjaworriar8964 2 года назад +1

    1. subList​(int fromIndex, int toIndex) -> for making sub list of arry
    2. trimToSize() -> for triming size of current arry

  • @ritikjha1497
    @ritikjha1497 2 года назад +1

    19:19
    removeAll- removes elements between given index.
    retainAll- removes all elements except for given by user

  • @godseye2733
    @godseye2733 3 года назад

    removeRange​(int fromIndex, int toIndex) :- remove elements from the list between given index
    subList​(int fromIndex, int toIndex) :- return the portion of the given list .
    for both methods :- 1st parameter index is inclusive 2nd parameter index is exclusive.

  • @samajit19
    @samajit19 Год назад

    1) isEmpty() ---> check whether the list is empty or not. return true if empty.
    2) remove(Object o) ------> Remove the first occurence element from list if more than 2 same element present.
    3) sublist() -----> make a other list from the parent list with the gived element range.

  • @shashwatgoyal
    @shashwatgoyal Год назад

    1) l1.subList(int fromIndex, int toIndex)
    Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
    2)l1.hashCode()
    Returns the hash code value for this list.

  • @callmesumant
    @callmesumant 5 месяцев назад

    1. forEach() method
    The forEach loop helps iterate over each element of the list and perform specific operation inline.
    Here for each element of the ArrayList l1, it is being incremented by 1 and then added to a new ArrayList l2.
    Ex:
    ArrayList l1 = new ArrayList();
    l1.add(3);
    l1.add(5);
    l1.add(2);
    l1.add(2);
    l1.add(6);
    l1.add(8);
    ArrayList l2;
    l1.forEach(number-> l2.add(number+1));
    System.out.println(l1);
    System.out.println(l2);
    Output:
    [3, 5, 2, 2, 6, 8]
    [4, 6, 3, 3, 7, 9]
    2. sublist(int fromIndex, int toIndex) method
    It returns a subset of the ArrayList within fromIndex to toIndex range (excluding toIndex)
    Ex:
    System.out.println(l1);
    l1.subList(2,5).clear();
    System.out.println(l1);
    Output:
    [3, 5, 2, 2, 6, 8]
    [3, 5, 8]

  • @aniruddhkanak679
    @aniruddhkanak679 Год назад

    1) equals: compares the object with the collection for equality check
    2)clone: It makes a copy of the desired arraylist

  • @joselitorebello6830
    @joselitorebello6830 3 года назад

    trimToSize() -> Basically sets the capacity of the ArrayList to current size
    isEmpty() -> Tells whether ArrayList is empty

  • @hetprajapati2327
    @hetprajapati2327 Год назад +1

    1) l1.removeIf(n -> n > 30) then it will remove elements greater than 30
    2) l1.ensureCapacity(10) , now it will ensure that arrayList has capacity of storing 10 elements. calling ensureCapacity with a value less than or equal to the current capacity has no effect. The ensureCapacity method is useful when you know in advance how many elements you are going to add to the ArrayList to minimize the number of reallocations

  • @GunjanAjayPandya
    @GunjanAjayPandya 9 месяцев назад +1

    listIterator()-->ArrayList class is used to return a list iterator over the elements in this list (in proper sequence).
    toArray() -->This method return the array which contains all the elements of arrayList return object array

  • @ashish4929
    @ashish4929 10 месяцев назад

    l1.add() -> adds the element in arraylist.
    l1.get() -> used to get element from arraylist so that we can print the elements.

  • @D-Coder440
    @D-Coder440 Год назад

    1. isEmpty(): This method is used to check if the ArrayList 'marks' is empty.
    It returns 'True' if the ArrayList is empty and 'False' if it is not."

    2. // retainAll(Collection c)
    mark1.retainAll(mark2);//-> This method retains only the common elements in 'mark2' when compared with 'mark1'."

  • @parth6034
    @parth6034 Год назад

    1) removeFirst() ----> Removes and returns the first element of this collection (optional operation).
    2) removeRange(int fromIndex, int toIndex)-----> Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.

  • @rohit45749
    @rohit45749 2 года назад +4

    1>. l1.isEmpty() -: it return true if the list is empty , otherwise return false
    2>. l1.trimToSize() -: it is used to trim the empty space in the Arraylist

  • @jeeasparant1995
    @jeeasparant1995 4 месяца назад +1

    l1.remove(6) removes the element which value is 6
    l1.retainall(l2) gives only the elements which common in both l1 and l2

  • @jayeshparmar2603
    @jayeshparmar2603 2 года назад +1

    1) size() :- it will return the total number of elements in list
    2) removeAll( arrayList ) :- it will remove all the elements from the list which are in arrayList.

  • @admiralxman2438
    @admiralxman2438 6 месяцев назад +1

    Iterator ref_var= name_arraylist.iterator() -》 used to get values of each element of arraylist.
    Clone()->make a shallow copy of arraylist

  • @User_02.64
    @User_02.64 5 месяцев назад +1

    //two new element for learning!
    System.out.println(l1.isEmpty() + (" -> Not Empty"));
    System.out.println(l1.subList(0,5));
    System.out.println(l1.retainAll(l2));
    l1.trimToSize();

  • @MeeranSiddiqui-zu5rn
    @MeeranSiddiqui-zu5rn Год назад

    (1) l1.clone() -> it gives the current copy of the l1 list .
    (2) ensureCapacity(int min Capacity) -> it set the minimum capacity of the list it be more as we required.

  • @puneetagrawal8596
    @puneetagrawal8596 6 месяцев назад +1

    1) getLast() --> This Method is used to get a last element in the Collection
    2) isEmpty() --> This method is used to return true if the list contains no element

  • @TheExamCentral
    @TheExamCentral 2 года назад +1

    L1.isEmpty() -> returns true if the list is empty
    L1.removeAll() -> remove all the elements of list
    L1.subList(int startIndex, int endIndex) -> return list from startIndex to endIndex excluding endIndex

  • @C_o_d_e_Help
    @C_o_d_e_Help Год назад

    1. set(int index, int element) : ye ksi index pe ek element ko replace kr deta hai;
    2. removeRange(int from, int to) : ye ek specified index se leke specified index tk list ko clear kr deta hai;

  • @rushikeshingole-m4w
    @rushikeshingole-m4w 9 месяцев назад

    1. System.out.println(l1.clone());// clone() method-> Returns a shallow copy of of this ArrayList Instance
    2.. System.out.println(l1.subList(2,3));//Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

  • @alnahian8051
    @alnahian8051 2 года назад +1

    My two methods are:
    subList(starting from, ending + 1): it returns a portion of the arraylist where we can specify from which index we want to see till the end index. But note that here we add 1 because the ending index we define in the method is exclusive. So in order to see the desired portion we have to add 1 at the ending index.
    hashCode(): returns the hash code value for this list

  • @codeyourmood8553
    @codeyourmood8553 2 года назад

    subList(int fromindex,int toindex) --> This method returns a list that contains the elements from first index to the last index that you had given as parameters for this method
    trimToSize() --> This method sets the capacity of the array list to the current number of elements to manage storage of the data .

  • @_devenderpal_
    @_devenderpal_ 4 года назад +1

    1.). toArray - ek esa array return krta hai jisme saare elements proper sequence me hote hain.
    2.) removesAll - ye method unn sabhi elements ko remove kar dega jo ek specified collection me hain

  • @amansinha7586
    @amansinha7586 2 года назад

    remove​(Object o) -----removes the element "o" if present in the arrayList
    subList​(int fromIndex, int toIndex)------ returns the elements from a specific index to a specific index

  • @sohitgupta7028
    @sohitgupta7028 2 года назад +1

    Collection.sort(l) :- array ko sort krr da gaaa simplly
    removerange(3,7) :- it remove all the element between 3 to 7

  • @anshulchoudhary2916
    @anshulchoudhary2916 2 года назад

    1] .subList(a,b) -> where a and b are the index in arraylist (a is included and b in excluded)
    2] .hashCode() -> provides the hashcode value of the arrayList

  • @swapnilkumarrai1175
    @swapnilkumarrai1175 2 года назад

    L1.isEmpty();
    Returns boolean
    L1.removeRange(int fromIndex, int toIndex);
    Reomve value b/w them including fromIndex excluding toIndex.

  • @vigneshv789
    @vigneshv789 3 года назад

    set: replaces the element which you want to add with the element which is present in that particular index.
    removeRange: removes group of elements within selected range

  • @shreyadasmahapatra5332
    @shreyadasmahapatra5332 4 года назад +16

    Harry sir we will be grateful if u help us in doing any major project in Java & C like u did in Python and thank u for helping us unconditionaly.

  • @mr.anonymous179
    @mr.anonymous179 3 года назад

    subList(start index , end index) -> ye ek list return karta hai similar to the one in python for those who don't know python, ye function start se leke end-1 index tak ke elements ko [ big bracket] me enclose karke deta hai.
    retainAll(collection) -> ye sirf un elements ko arrayList me retain karta hai jo pass kiye hue collection me hai .

  • @Kinggaming-hp3qp
    @Kinggaming-hp3qp 2 года назад

    Collections.sort(list_name) : it sort the arraylist.
    TrimToSize(list_name) : it teduce the arraylist size equal to the number of element exist in arraylist.

  • @theaayushadhana
    @theaayushadhana Год назад

    Bahi documentation sach me kamal h or samjh me aa rhi h bro wow so goooooooodd

  • @ahmedharoon4013
    @ahmedharoon4013 3 месяца назад +1

    1) "toArray()" : this method will convert the data type of all the elements from "Arraylist" to "Array"
    2) "isEmpty()" : this method will check if the Arraylist is empty or not. If it is empty, it will return true.

    • @amityadav0021
      @amityadav0021 3 месяца назад

      bro is playlist ko krne ke baad keh skte hai ki hume core java ati hai??????? ya or bhi kuch reh gya h core sikhne ke liye

  • @Vivekpandey-cy1ul
    @Vivekpandey-cy1ul 3 года назад +2

    removeRange : It helps you to remove the element from the from the first index till the index you want to removed.
    retainAll: It only provide the value which are actual present in the list. otherwise it will throw an exception ClassCastException

  • @baleginda8183
    @baleginda8183 3 года назад

    at 12.11 it is clarified.good job.

  • @innocentgamer8670
    @innocentgamer8670 Год назад

    toArray() - Returns an array containing all of the elements in this list in proper sequence
    get(int index) - Returns the element at the specified position in this list.

  • @availableignouassignments2518
    @availableignouassignments2518 Год назад

    l1.trimToSize() : The Capacity of Array will become equal to the capacity of Current Array
    Sout : l1.subList(Range of Index) : Helps in printing a Range out of Array

  • @harshitshrivas5444
    @harshitshrivas5444 8 месяцев назад +2

    1) Collection.sort(1); = This number will sort the number from less to high
    2) l1.remove(2) = Its delete / remove the number in that element...
    😇😇

  • @karansingh02
    @karansingh02 4 года назад

    Thank u so much harry bhai mai aapka Course Starting se dhek raha hai hu

  • @pythoncoder0072
    @pythoncoder0072 3 года назад

    removeRange(int fromIndex, int toIndex) ---> removes all the elements between 'fromIndex' and 'toIndex'.
    trimToSize() ---> trims the ArrayList's capacity to the current size.
    For example -> If u have set an ArrayList to be10 integers and u have added only 5 integers then this function will change the capacity from 10 to 5.

  • @Unknown-Stranger
    @Unknown-Stranger 4 года назад +17

    removeRange​(int fromIndex, int toIndex) -> ye method kis index se kha tak elements remove karne h waha kaam aata h
    trimToSize() -> ArrayList ki Capacity ko uske size ke equal kardega

  • @atul8423
    @atul8423 Год назад +1

    1) l1.size ( ) -> Return the number of size in this collection.
    2) l1.isEmpty( ) -> Return true when our method is empty otherwise return false.

  • @vsvlog6326
    @vsvlog6326 3 года назад

    1.
    clone() :- Return a shallow copy of this ArrayList instance.
    2.
    is empty() :- Returns true if this list contains no elements.
    👍👍🙏Thank u sir 🙏

  • @AnkushSaral
    @AnkushSaral Год назад

    removeAll(collection c): Is method ka use karke ham hamare current collection mai se specified collection ke all elements ko remove kar sakte hain.
    subList(int fromIndex, int toIndex): Ye ek sublist return karega jisme vo element honge jo specified index range ke beech Mai honge.
    Note-> toIndex is exclusive.

  • @iamcoder7030
    @iamcoder7030 2 года назад

    l1.subList(2,6) return a sublist form 2 to 6 index
    l1.removeIf(n -> ((n % 3) == 0)); delete number which is divisable by 3 from the array

  • @Deepaktut
    @Deepaktut 2 года назад

    Remove (int index) ==> It is remove elements from the specific position.
    trimToSize() ==> Trims the capacity of this ArrayList instance to be the list's current size.

  • @shubhamchauhan3706
    @shubhamchauhan3706 4 года назад +1

    Iterator()
    List subList(int fromIndex, int toIndex);

  • @varadpawar4241
    @varadpawar4241 3 года назад

    toArray() - This converts an Array list into an array.
    removeAll​(Collection c) - Removes all elements from the arraylist which are present in the collection given in as argument.

  • @falconlol8284
    @falconlol8284 11 дней назад

    1 .
    .equals().
    returns true if the all elements in obj1 are present in obj2 in the same order
    and returns false if not present in obj2 or not in same order
    2. .trimToSize();
    this sets the size of the list from initial defined capacity to whatever number of elements currently in the list .

  • @sandipanmondal8069
    @sandipanmondal8069 4 года назад +4

    Thank you sir for such a very very beautiful course..

  • @deveshsalke8962
    @deveshsalke8962 3 года назад

    sublist(int start, int end) - returns a small list or a sub list of the main array list from the index start(main array list) to index end
    toArray()- returns an array version of our arraylist

  • @sirphiriladki5531
    @sirphiriladki5531 4 дня назад

    remove​(int index) -- remove the element, whose index we write in function
    trimToSize()--- it will trim the size of arraylist according to the element present , basically remove extra space.