ArrayList in Java: Demo & Methods

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ม.ค. 2025

ความคิดเห็น • 843

  • @thatcoolkid370
    @thatcoolkid370 3 ปีที่แล้ว +40

    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

  • @adhyakeshri355
    @adhyakeshri355 3 ปีที่แล้ว +204

    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

  • @amritachaudhari6473
    @amritachaudhari6473 ปีที่แล้ว +127

    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 8 หลายเดือนก่อน +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 4 หลายเดือนก่อน +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 4 หลายเดือนก่อน

      like intersection!

  • @vishwasbist1974
    @vishwasbist1974 3 ปีที่แล้ว +41

    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?

  • @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!!

  • @ashutoshranjan4644
    @ashutoshranjan4644 3 ปีที่แล้ว +50

    •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 ปีที่แล้ว +30

    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

  • @Mohit_Saini_YT
    @Mohit_Saini_YT 4 ปีที่แล้ว +127

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

  • @achintyagupta1991
    @achintyagupta1991 10 หลายเดือนก่อน +1

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

  • @himanshusharma2335
    @himanshusharma2335 ปีที่แล้ว +7

    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 21 วันที่ผ่านมา +2

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

  • @kanchansharma9692
    @kanchansharma9692 6 หลายเดือนก่อน +3

    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

  • @sriharivernekar2255
    @sriharivernekar2255 2 ปีที่แล้ว

    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.

  • @HarshVardhan-bx4pv
    @HarshVardhan-bx4pv 4 ปีที่แล้ว +13

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

  • @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.

  • @raahulsuman4922
    @raahulsuman4922 3 ปีที่แล้ว

    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

  • @Saurav1-d4f
    @Saurav1-d4f ปีที่แล้ว +1

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

  • @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.

    • @BeingSamjdar
      @BeingSamjdar 3 ปีที่แล้ว

      nhi run hue dono

    • @123rajat.sharma
      @123rajat.sharma 3 ปีที่แล้ว

      nhi chl rhe bhai 1 bar check kar lena

  • @puneetshakya3001
    @puneetshakya3001 4 ปีที่แล้ว +12

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

  • @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.

  • @kpurnachandrapavan845
    @kpurnachandrapavan845 2 ปีที่แล้ว +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();

  • @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

  • @donbrad5079
    @donbrad5079 7 หลายเดือนก่อน +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 .

  • @krishnawadhwani5393
    @krishnawadhwani5393 4 ปีที่แล้ว +5

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

  • @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.

  • @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' .

  • @ahmad.sln.4
    @ahmad.sln.4 4 หลายเดือนก่อน +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.

  • @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.

  • @farhaddubey
    @farhaddubey ปีที่แล้ว +1

    Haarry Bhiya is just Amazing Love U....🥰🥰🥰🥰🥰🥰🥰🥰🥰🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🥀🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹

  • @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

  • @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);

  • @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

  • @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

  • @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 🙏

  • @Sunil2024-n9h
    @Sunil2024-n9h หลายเดือนก่อน +1

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

  • @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).

  • @joselitorebello6830
    @joselitorebello6830 3 ปีที่แล้ว

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

  • @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.
    👍

  • @Sumitraik-bj1uw
    @Sumitraik-bj1uw 10 วันที่ผ่านมา

    1.> hashCode() => hashCode() ek built-in method hai jo kisi object ke liye ek unique number (hash code) deta hai. Ye hash code object ki content aur memory address ke adhar par banata hai.
    2.> toArray() -> ArrayList class ki ek method hai jo ArrayList ko ek array mein convert karke naya array return karti hai.
    Arrays static hote hain, yaani unka size fixed hota hai aur ek baar array banane ke baad hum uska size change nahi kar sakte. Lekin ArrayList dynamic hoti hai, iska size badal sakta hai jab hum elements ko add ya remove karte hain.

  • @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

  • @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.)

  • @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.

  • @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

  • @OmGupta
    @OmGupta 4 ปีที่แล้ว +4

    Congratulations for 950k subscribers 🔥🔥🔥

  • @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);

  • @jeeasparant1995
    @jeeasparant1995 5 หลายเดือนก่อน +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

  • @aashutoshkumar8597
    @aashutoshkumar8597 2 ปีที่แล้ว +1

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

  • @jaded-6153
    @jaded-6153 วันที่ผ่านมา

    1. toArray() -> Used to make an array from an ArrayList.
    2. ensureCapacity() -> Used to set the capacity of the ArrayList.

  • @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

  • @harshitshrivas5444
    @harshitshrivas5444 9 หลายเดือนก่อน +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...
    😇😇

  • @someshsahu4638
    @someshsahu4638 3 ปีที่แล้ว +1

    Nice explanation sir thankyou so much 🙏🏼🙏🏼🙏🏼

  • @sandipanmondal8069
    @sandipanmondal8069 4 ปีที่แล้ว +4

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

  • @ninjaworriar8964
    @ninjaworriar8964 2 ปีที่แล้ว +1

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

  • @Kishan_Narrator
    @Kishan_Narrator 2 ปีที่แล้ว

    toArray - returns object , i think it converts array list into array , i can perform array functions after i use l1.toArray
    sublist(3,6) - retuns arraylist , it will give sublist of 3,4,5 indexes

  • @puneetagrawal8596
    @puneetagrawal8596 7 หลายเดือนก่อน +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

  • @anmolgaur8965
    @anmolgaur8965 2 ปีที่แล้ว

    l1.clone() Returns a shallow copy of this ArrayList instance.
    l1.toarray() returns an array with index from lfirst to last
    Harry bhai thanks for the course gonna finish it soon ..

  • @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.

  • @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

  • @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

  • @GopiKishanSahu-u6k
    @GopiKishanSahu-u6k 29 วันที่ผ่านมา +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.

  • @ashish4929
    @ashish4929 11 หลายเดือนก่อน

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

  • @theDivyanshuSrivastava
    @theDivyanshuSrivastava 11 หลายเดือนก่อน

    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

  • @ashutoshjoshiuni-3984
    @ashutoshjoshiuni-3984 4 ปีที่แล้ว

    Can't wait for 1 million subscribers
    I subscribed you when you are at 2 lakhs but now sir 1 million
    Amazing ❤️❤️
    Love you sir ji
    From punjab❤️🔥🎉

  • @aniruddhkanak679
    @aniruddhkanak679 ปีที่แล้ว

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

  • @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.

  • @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.

  • @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

  • @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]

  • @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

  • @sayantanhalder1056
    @sayantanhalder1056 6 หลายเดือนก่อน +3

    num.removeLast() -> Removes and returns the last element of this collection (optional operation). num.removeFirst() -> Removes and returns the first element of this collection (optional operation). 😀😎

  • @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 10 หลายเดือนก่อน +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

  • @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.

  • @_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

  • @sathiyaseelanudaiyar8426
    @sathiyaseelanudaiyar8426 4 ปีที่แล้ว +6

    pls upload java data structure course as well.

  • @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'."

  • @aryantomar8914
    @aryantomar8914 2 ปีที่แล้ว

    you made this looks too easy i have been trying to understand this package, BTW THANKS

  • @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;

  • @mrutyunjayapradhan3599
    @mrutyunjayapradhan3599 2 ปีที่แล้ว +1

    Feeling blessed sir ,for the way you teach us is outstanding

  • @RehanAliArman
    @RehanAliArman 8 หลายเดือนก่อน

    great you are very great teacher and programmer

  • @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.

  • @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.

  • @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.

  • @User_02.64
    @User_02.64 6 หลายเดือนก่อน +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();

  • @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.

  • @ritikjha1497
    @ritikjha1497 2 ปีที่แล้ว +1

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

  • @manoor0858
    @manoor0858 7 หลายเดือนก่อน +1

    toArray() - will make the arraylist an array
    trimToSize() - if we have 100 size elemetn but the arraylist has only 6 elements,after applying this ,the arraylist will have its size reduced to 6

  • @joelmarkjmj
    @joelmarkjmj 2 ปีที่แล้ว +1

    Your playlist looks like a ready made halwa for me....I'm so hungry!!!!!

  • @dips12348
    @dips12348 7 หลายเดือนก่อน +1

    1.isEmpty() checks if list has no elements or not.
    2.Iterator() returns an iterator over elements in list

  • @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.

  • @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

  • @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

  • @abhishektyagialwayswins777
    @abhishektyagialwayswins777 2 ปีที่แล้ว +1

    trimToSize() it reduce the size to index that are filled
    removeAll(List2) removes elements of list1 that are present in List 2

  • @sirphiriladki5531
    @sirphiriladki5531 23 วันที่ผ่านมา

    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.

  • @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

  • @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

  • @AnandMishra-rn4tp
    @AnandMishra-rn4tp 6 หลายเดือนก่อน

    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

  • @rushikeshingole-m4w
    @rushikeshingole-m4w 10 หลายเดือนก่อน

    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.

  • @karansingh02
    @karansingh02 4 ปีที่แล้ว

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

  • @Samiksha.code24
    @Samiksha.code24 ปีที่แล้ว

    grateful to learn from you sir!! Your efforts are truly commendable
    this course has helped me learn oops in java and score well in my college examinations as well.