Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » Need some help regarding arraylist
Need some help regarding arraylist [message #178791] Sat, 09 September 2006 12:22 Go to next message
Eclipse UserFriend
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 13:05 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 01:28:12 EDT 2025

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

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

Back to the top