Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Need some help regarding arraylist
Need some help regarding arraylist [message #178791] Sat, 09 September 2006 16:22 Go to next message
SarayuGeethanjali is currently offline SarayuGeethanjaliFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

ArrayList arrL = new ArrayList();
ArrayList tmpArrL = new ArrayList();

for (int i = 0; i < size; i++) {
Character ch = new Character(text.charAt(i));
arrL.add(ch);
}
tmpArrL = arrL;
------;
------;
String newText = "";
for (int i = 0; i < arrL.size(); i++) {
newText += tmpArrL.get(i);
}
return newText;

In some cases the arraylist contains around 500000 characters. in this
situtation tool gets hanged and it takes alot of time to execute the for
loop.

Please let me know how to handle this situation.

Thanks,
Re: Need some help regarding arraylist [message #178805 is a reply to message #178791] Sat, 09 September 2006 17:05 Go to previous message
David Williams is currently offline David WilliamsFriend
Messages: 722
Registered: July 2009
Senior Member
On Sat, 09 Sep 2006 12:22:28 -0400, Sarayu Geethajali =

<sarayu_geetha@yahoo.com> wrote:

> Hi,
>
> ArrayList arrL =3D new ArrayList(); ArrayList tmpArrL =3D new ArrayLis=
t();
>
> for (int i =3D 0; i < size; i++) {
> Character ch =3D new Character(text.charAt(i));
> arrL.add(ch);
> }
> tmpArrL =3D arrL; ------;
> ------;
> String newText =3D "";
> for (int i =3D 0; i < arrL.size(); i++) {
> newText +=3D tmpArrL.get(i);
> }
> return newText;
>
> In some cases the arraylist contains around 500000 characters. in this=
=

> situtation tool gets hanged and it takes alot of time to execute the f=
or =

> loop. Please let me know how to handle this situation.
>
> Thanks,
>

This is not a webtools quesion, just a plain java question, so there mig=
ht =

be more
appropriate newgroups for you to join ... but to offer one suggestion,

you should use StringBuffer, instead of creating so many new Strings wit=
h
newText +=3D tmpArrL.get(i)
Previous Topic:WST 1.5.0 with Maven 2.0 dependencies running on Tomcat
Next Topic:I have an Eclipse problem
Goto Forum:
  


Current Time: Sun Sep 22 03:36:21 GMT 2024

Powered by FUDForum. Page generated in 0.03201 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top