tag:blogger.com,1999:blog-694855878384792308.post7607454174139338379..comments2024-03-21T06:26:49.387-07:00Comments on Java67: 2 Ways to Remove Elements/Objects From ArrayList in Java [Example]javin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-694855878384792308.post-81423108412179216142020-08-26T01:49:22.949-07:002020-08-26T01:49:22.949-07:00yo fam... list.remove() doesn't work... it has...yo fam... list.remove() doesn't work... it has to be iterator.remove()Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-12626988149539256792018-08-11T09:41:45.078-07:002018-08-11T09:41:45.078-07:00But lets ay i have a class stored in my arraylist....But lets ay i have a class stored in my arraylist. how do I remove that?<br />Anonymoushttps://www.blogger.com/profile/12807335126183239213noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-55382547625038511332017-06-21T07:59:33.295-07:002017-06-21T07:59:33.295-07:00Hello Bruno, that call will create error because o...Hello Bruno, that call will create error because of auto-boxing the call become confusing, remove(1) will resolve to both remove(int index) and remove (Object obj). This is one of the thing you should be careful while overloading methods. See my <a href="http://javarevisited.blogspot.com/2013/01/java-best-practices-method-overloading-constructor.html" rel="nofollow">explanation</a> about that to learn more. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-9562397772897780802017-06-21T06:24:36.895-07:002017-06-21T06:24:36.895-07:00I was left with a doubt...
When you do remove the...I was left with a doubt... <br />When you do remove the index or the object, <br />How do the method knows, if I´m inputting the Index, or the Object??<br /><br />if you have a ArrayList with [1, 1, 2, 2]<br /><br />But you want to remove the second number 1????<br />will you do arrayList.remove(1); ???? <br />It will remove the two numbers one??? How does it knows, if you use the same <br />method name??? remove?Anonymoushttps://www.blogger.com/profile/02965783596229526434noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-57948323634395589022017-03-15T02:01:40.861-07:002017-03-15T02:01:40.861-07:00that's incorrect. it does delete 300.
ArrayLi...that's incorrect. it does delete 300.<br /><br />ArrayList Before : [101, 200, 300, 400]<br />ArrayList After : [101]<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-52001938261753059762016-12-09T04:43:13.830-08:002016-12-09T04:43:13.830-08:00simply superbsimply superbThaaye Thunaihttps://www.blogger.com/profile/09108216126297129690noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-21959448429102513502015-12-05T19:01:38.570-08:002015-12-05T19:01:38.570-08:00You man deserve a medal!
Simply outstanding!! fr...You man deserve a medal! <br /><br />Simply outstanding!! from A to Z!!<br />Coherent and concise!!<br /><br />Thanks a lot.Anonymoushttps://www.blogger.com/profile/03076096768683056947noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-14371122952090701852015-11-10T02:16:48.998-08:002015-11-10T02:16:48.998-08:00nice post nice post Anonymoushttps://www.blogger.com/profile/09945022042017976682noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-77400513770230104642015-09-04T23:00:52.260-07:002015-09-04T23:00:52.260-07:00Hi,
if I have an arraylist of (1,2,3,2,3,4,5,22,...Hi, <br /><br />if I have an arraylist of (1,2,3,2,3,4,5,22,33,34,4,1,2,3,4,5) and I want to remove another arraylist (1,2,3) how shold I do it? I tried removeAll and it shows some error during execution.LK888https://www.blogger.com/profile/01499450007024966746noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-70129676092309264402015-08-12T10:25:33.001-07:002015-08-12T10:25:33.001-07:00Java 8 streams provide a very simple way to remove...Java 8 streams provide a very simple way to remove duplicate elements from a list. Using the distinct method.<br /> If there is a list of cities cityList then duplicates from that list can be removed in a single line like this - <br /> cityList = cityList.stream().distinct().collect(Collectors.toList());infojhttp://netjs.blogspot.in/2015/08/how-to-remove-duplicate-elements-from-arraylist-java.htmlnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-9804884140037143962015-07-31T11:29:58.728-07:002015-07-31T11:29:58.728-07:00Good Explanation Good Explanation kartik kudadahttps://www.blogger.com/profile/08086600138252617955noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-11249755563000889972015-07-17T00:57:46.893-07:002015-07-17T00:57:46.893-07:00thank youthank youAnonymoushttps://www.blogger.com/profile/09585451475285552636noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-67134688450243624702015-06-10T04:16:10.624-07:002015-06-10T04:16:10.624-07:00it doesnt work for 101,200,300,400
bcoz as soon as...it doesnt work for 101,200,300,400<br />bcoz as soon as u delete 200 iterator points to 400 (so it wont delete 300 even though its a even number)sathwickhttps://www.blogger.com/profile/06463337125611054968noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-37756420814309973972015-03-06T02:12:52.195-08:002015-03-06T02:12:52.195-08:00Thank you .. awesome . Thank you .. awesome . Sanhttps://www.blogger.com/profile/16766062955299531125noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-9888872593948253792015-02-24T03:43:42.567-08:002015-02-24T03:43:42.567-08:00awesome explanationawesome explanationSuman Kumarhttps://www.blogger.com/profile/17691880339727926991noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-81275757714207860502014-05-20T02:17:28.044-07:002014-05-20T02:17:28.044-07:00Simple and sweet post!Simple and sweet post!Anonymoushttps://www.blogger.com/profile/09111588308863401026noreply@blogger.com