Java: using foreach over strings from arrayList does not print anything

Posted by HH on Stack Overflow See other posts from Stack Overflow or by HH
Published on 2010-04-11T01:48:47Z Indexed on 2010/04/11 1:53 UTC
Read the original article Hit count: 352

Filed under:
|
|
$ javac ArrayListTest.java 
$ java ArrayListTest 
$ cat ArrayListTest.java 
import java.io.*;
import java.util.*;

public class ArrayListTest{

    public static void main(String[] args) {
        try {
            String hello ="oeoaseu oeu hsoae sthoaust hoaeut hoasntu";
            ArrayList<String> appendMe = null;

            for(String s : hello.split(" "))
                appendMe.add(s+" ");

            for(String s : appendMe)
                System.out.println(s);
            //WHY DOES IT NOT PRINT?
        }catch(Exception e){
        }
    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist