tag:blogger.com,1999:blog-8712770457197348465.post5215360463530788288..comments2024-03-18T23:01:42.768-07:00Comments on Javarevisited: How to use ArrayList in Java? 10 Examples of ArrayListjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-8712770457197348465.post-55127265931737770822016-01-18T05:55:23.162-08:002016-01-18T05:55:23.162-08:00@Anonymous, Can you please care to explain your lo...@Anonymous, Can you please care to explain your long programs? Also in which language they are, never heard something like ListazIdjavin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-53432845953428739562016-01-18T05:49:08.362-08:002016-01-18T05:49:08.362-08:00public class AutoLerakat {
private ArrayList ...public class AutoLerakat {<br /><br /> private ArrayList autok = new ArrayList();<br /><br /> public AutoLerakat() {<br /> }<br /><br /> public void eladoAuto(int id) {<br /> for (Auto a : this.autok) {<br /> if (a.getId() == id) {<br /> this.autok.remove(a);<br /> break;<br /> }<br /> }<br /> }<br /><br /> publicAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-83957596715263413372016-01-18T05:44:52.739-08:002016-01-18T05:44:52.739-08:00scanner.nextLine();
if (line.length() ...scanner.nextLine();<br /> if (line.length() != 0) {<br /> System.out.println("***Line: " + line);<br /> StringTokenizer stk = new StringTokenizer(line, ", .;:?!");<br /> int id = Integer.parseInt(stk.nextToken());<br /> String marka = stk.nextToken();<br /> String szin = stk.nextToken();<br /Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-86931569594879921372016-01-18T05:41:06.562-08:002016-01-18T05:41:06.562-08:00public class Feldolgozas {
ArrayList dolg = n...public class Feldolgozas {<br /><br /> ArrayList dolg = new ArrayList();<br /> ArrayList hall = new ArrayList();<br /> ArrayList szak = new ArrayList();<br /> ArrayList tan = new ArrayList();<br /><br /> public void Dolg_beol(String filename) {<br /> Scanner scan = null;<br /> try {<br /> scan = new Scanner(new File(filename));<br /> } catch (Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-37962470065786214782016-01-12T05:54:37.568-08:002016-01-12T05:54:37.568-08:00superb articles on ArrayList in java very nice.......superb articles on ArrayList in java very nice.....learnprogramingbyluckysirhttps://www.blogger.com/profile/09431252920772106799noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-24347222987822219202015-11-27T01:10:39.150-08:002015-11-27T01:10:39.150-08:00how i can loop an arraylist of objectshow i can loop an arraylist of objectsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-52007480622842162772015-11-06T09:57:33.274-08:002015-11-06T09:57:33.274-08:00Can you please explain how can write custom ArrayL...Can you please explain how can write custom ArrayList without using Collection?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-65012546969026003312015-06-18T09:07:17.286-07:002015-06-18T09:07:17.286-07:00If anybody is interested on some ArrayList base in...If anybody is interested on some ArrayList base interview question, which is very important from Java interview point of view, can see this <a href="http://java67.blogspot.co.uk/2015/06/20-java-arraylist-interview-questions.html" rel="nofollow">list</a>, which contains questions contributed by community.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-17173312418544561072013-08-21T20:21:11.848-07:002013-08-21T20:21:11.848-07:00Hello Javin, What is difference between capacity a...Hello Javin, What is difference between capacity and size of ArrayList in Java? Also what is the default capacity when we create instance of ArrayList as aList = new ArrayList(). It would be nice, if you can also explain, how ArrayList resize itself dynamically by using load factor and capacity, as I still has to get hold of this piece. Shanenoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-43856727661774747752013-08-18T18:32:22.501-07:002013-08-18T18:32:22.501-07:00Dear Sir,
Your articles about Java, and therefore...Dear Sir,<br /><br />Your articles about Java, and therefore this blog, are a big help to me.<br /><br />I am trying to learn the Java programming language and every time i come across something new i check your blog for a tutorial explaining this new subject.<br /><br />I like to thank you and keep up the good work.<br /><br />Sincerely,<br />Marc.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-8056892159030459402013-08-07T21:22:30.693-07:002013-08-07T21:22:30.693-07:00Hello Javin, I am getting following error, java.ut...Hello Javin, I am getting following error, <b>java.util.arraylist cannot be cast to java.lang.string</b> while converting ArrayList to String e.g.<br /><br />ArrayList listOfStudents = getListOfStudents();<br />String content = (String) listOfStudents;<br /><br />Can you please help?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-44343151129383615472013-04-24T04:20:28.067-07:002013-04-24T04:20:28.067-07:00Very nice article..Appreciate for your efforts.Tha...Very nice article..Appreciate for your efforts.Thanks and Keep Posting More...Pritam_Ghoshhttps://www.blogger.com/profile/00201002441525624780noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-24932746253443133972012-12-14T06:51:24.892-08:002012-12-14T06:51:24.892-08:00**Correction **
ArrayList stringList = Arrays.asL...**Correction **<br /><br />ArrayList stringList = Arrays.asList(new String[]{"One", "Two", "Three");<br /><br />should be<br /><br />ArrayList stringList = new ArrayList( Arrays.asList(new String[]{"One", "Two", "Three"}));<br /><br />The list, returned from 'Arrays.asList', needs casting to an Arraylist. Also a '}' was Anonymoushttps://www.blogger.com/profile/14829872395942984250noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6947789070023204412012-06-23T20:08:41.080-07:002012-06-23T20:08:41.080-07:00@Raaki, I see what you are saying. actually it was...@Raaki, I see what you are saying. actually it was ArrayList i.e. generic version of ArrayList to store only Strings. some how those angle bracket lost, must be I have use them as literal instead of escape version like <. Anyway Thanks for pointing it out.Javin @ decorator pattern examplehttp://javarevisited.blogspot.com/2011/11/decorator-design-pattern-java-example.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-84049745277445403342012-06-23T19:29:38.441-07:002012-06-23T19:29:38.441-07:00First of all the statement "This Java ArrayLi...First of all the statement "This Java ArrayList will only allow String and will throw compilation error if we try to any other object than String.<br />ArrayList stringList = new ArrayList();" is wrong and the QA2 is stupid.. its better to test the code & concept b4 do post in this forum..!!<br /><br />See the below example:<br /><br />package workset1;<br /><br />import java.util.*Raakihttp://javashoreblog.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-17264706361480456752012-04-12T23:37:04.934-07:002012-04-12T23:37:04.934-07:00How can I get middle element from ArrayList, how t...How can I get middle element from ArrayList, how to get first and last element form elements, though I have an idea that first element is zero and last element should be size-1, I am worrying about empty ArrayList,may be some API methods already out there. Another thing I am intersted in SubList, i.e. part of ArrayList from one index to another, let me know how can we find sublist from ArrayList Jackobnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-69039056142962822722012-02-28T23:20:28.128-08:002012-02-28T23:20:28.128-08:00hello.if i want to display two things in one item...hello.if i want to display two things in one item like contact number and name then how can add in listarray?plz reply me on jagruti.sangani@inextrix.comAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-70933513938255790352012-01-29T21:11:08.823-08:002012-01-29T21:11:08.823-08:00Best ArrayList tutorial in Java, easily explained ...Best ArrayList tutorial in Java, easily explained most of the task java programmer should perform with ArrayList. would have been even better if you have included sorting and searching on Arraylist in Java.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-77008679097495490192012-01-12T18:37:56.641-08:002012-01-12T18:37:56.641-08:00for (int i = 0; i
String item = stringList.get(...for (int i = 0; i<br /> String item = stringList.get(i);<br />}<br /><br />Why all the errors and non-working code examples???Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-41028972775128682312012-01-06T04:32:17.666-08:002012-01-06T04:32:17.666-08:00what is difference in two code example, sorry Can ...what is difference in two code example, sorry Can you please highlight , both arraylist examples looked same to me.Javin @ String split Java examplehttp://javarevisited.blogspot.com/2011/09/string-split-example-in-java-tutorial.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-26118195179901574242012-01-05T09:55:48.282-08:002012-01-05T09:55:48.282-08:00I'm not an expert, but I think the code from #...I'm not an expert, but I think the code from #1:<br /><br />ArrayList stringList = new ArrayList();<br /><br />Would be more correctly stated as<br /><br />ArrayList stringList = new ArrayList();<br /><br />Please advise.SteveInMAhttps://www.blogger.com/profile/04677633047431089844noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-2753411921445793792011-12-28T03:04:12.436-08:002011-12-28T03:04:12.436-08:00@johmif thanks for your comment and good to know t...@johmif thanks for your comment and good to know that you like this Java arraylist example and tutorial. @Advait when we create ArrayList(int initialCapacity) we specify size otherwise it will start with default size which is 10 and re-size it accordingly. resizing of arraylist is time consuming operation because content of one array is copied into another array. so if you know the size in Javin @ spring interview questions answershttp://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-69116883950289570032011-12-22T05:28:00.273-08:002011-12-22T05:28:00.273-08:00Assuming capacity is more elements are not going t...Assuming capacity is more elements are not going to be added once ArrayList is populated, consider this - create an array list using "new ArrayList(int initialCapacity)" ? Will it perform better compared to an ArrayList created by "new ArrayList();"Anonymoushttps://www.blogger.com/profile/14392984062993643571noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-17522209125592835932011-12-21T21:25:39.705-08:002011-12-21T21:25:39.705-08:00What is advantage of iterating through ArrayList a...What is advantage of iterating through ArrayList as compared to looping through ArrayList ? i.e. I can get elements from ArrayList by using Iterator or by using get(index) method , which one is faster and which one is better , please elaborate ?Chen pengennoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-43942791205786568562011-12-16T00:43:10.721-08:002011-12-16T00:43:10.721-08:00nice examples. here is my example using objects no...nice examples. here is my example using objects not with an primitive data types. <br />http://www.myrmidons.co.in/2011/11/core-java-list-and-arraylist-example.htmlAnonymoushttps://www.blogger.com/profile/09122533940640970927noreply@blogger.com