Rabbit3cat
03-05-2006, 04:16 PM
I am trying to add the elements in a list to the end of a string using concat, but it is not working for me. Below is the code i have written
import java.util.*;
public class concat {
public static void main(String[] args) {
String hello = "hello";
List list1 = new ArrayList();
list1.add("one");
list1.add("two");
list1.add("three");
Iterator iter = list1.iterator();
while(iter.hasNext()) {
Object e = iter.next();
System.out.println(e.toString());
hello.concat(e.toString());
}
System.out.println(hello);
}
}
Can anybody see why this is not working?
Thanks
import java.util.*;
public class concat {
public static void main(String[] args) {
String hello = "hello";
List list1 = new ArrayList();
list1.add("one");
list1.add("two");
list1.add("three");
Iterator iter = list1.iterator();
while(iter.hasNext()) {
Object e = iter.next();
System.out.println(e.toString());
hello.concat(e.toString());
}
System.out.println(hello);
}
}
Can anybody see why this is not working?
Thanks