set arraylist element as null

Posted by Jessy on Stack Overflow See other posts from Stack Overflow or by Jessy
Published on 2010-03-31T22:39:54Z Indexed on 2010/03/31 22:43 UTC
Read the original article Hit count: 183

Filed under:
|
|

The first index is set to null (empty), but it doesn't print the right output, why?

//set the first index as null and the rest as "High"
String a []= {null,"High","High","High","High","High"};

//add array to arraylist
ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a)); 

for(int i=0; i<choice.size(); i++){
   if(i==0){
       if(choice.get(0).equals(null))
           System.out.println("I am empty");  //it doesn't print this output
    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist