tag:blogger.com,1999:blog-694855878384792308.post3120240101384690272..comments2024-03-21T06:26:49.387-07:00Comments on Java67: How to Convert a Comma Separated String to an ArrayList in Java - Example Tutorialjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-694855878384792308.post-86269362293688230172018-11-17T04:41:21.563-08:002018-11-17T04:41:21.563-08:00The output elements are a single space, what is yo...The output elements are a single space, what is your problem? <br />Output: "[Apple, Google, Samsung]" — Google and Samsung with one space.Anonymoushttps://www.blogger.com/profile/17623920851399192310noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-16682995290919142872018-03-05T04:15:19.798-08:002018-03-05T04:15:19.798-08:00Yes, definitely, just write code to convert String...Yes, definitely, just write code to convert String to your object that's it. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-89019607889013122422018-03-04T07:05:45.847-08:002018-03-04T07:05:45.847-08:00can we use the same methodology to create an objec...can we use the same methodology to create an object list from the comma separated string? Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-28310028757051859642017-10-04T05:51:55.332-07:002017-10-04T05:51:55.332-07:00Good for explanation, but still teaching wasting R...Good for explanation, but still teaching wasting RAM. Don't instantiate temporary variables if not needed.<br /><br />List los = Arrays.asList( commaSeparatedList );<br /><br />Wham bam done.<br /><br />Java has a very finite amount of memory to save data. Don't waste it on nonessential instantiation of classes.Anonymoushttps://www.blogger.com/profile/18415740765117691287noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-29196625164184807172017-09-24T23:14:08.327-07:002017-09-24T23:14:08.327-07:00Hi,
I have written a program based on ur explanat...Hi,<br /><br />I have written a program based on ur explanation and tried to add element after creating copy arraylist see the program and result and please explain y the new item not added into list.<br /><br />public class ArraytoArrayList {<br /><br /> public void StringToArrayLsit(String str){<br /> <br /> String[] stringArray= str.split(",");<br /> <br /> List stringList = Arrays.asList(stringArray);<br /> System.out.println("List Before ADD : " +stringList);<br /> <br /> ArrayList CopyList =new ArrayList<>(stringList);<br /> CopyList.add("test");<br /> <br /> System.out.println("List After ADD : " +stringList);<br /> <br /> }<br /> <br /> public static void main(String[] args) {<br /> String str = "java,j2ee,core java";<br /> ArraytoArrayList aal=new ArraytoArrayList();<br /> aal.StringToArrayLsit(str);<br /> }<br /><br />}<br /><br />Result:<br />List Before ADD : [java, j2ee, core java]<br />List After ADD : [java, j2ee, core java]<br /><br />why "test" is not added into list ?<br />Anonymousnoreply@blogger.com